block/hmp: Allow info = NULL in print_block_info()
This allows printing infos of BlockDriverStates that aren't at the root of the graph (and logically implementing a BlockBackend). Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
		
							parent
							
								
									289b276c69
								
							
						
					
					
						commit
						8d6adccda2
					
				
							
								
								
									
										16
									
								
								hmp.c
								
								
								
								
							
							
						
						
									
										16
									
								
								hmp.c
								
								
								
								
							| 
						 | 
				
			
			@ -295,7 +295,21 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
 | 
			
		|||
{
 | 
			
		||||
    ImageInfo *image_info;
 | 
			
		||||
 | 
			
		||||
    assert(!info || !info->has_inserted || info->inserted == inserted);
 | 
			
		||||
 | 
			
		||||
    if (info) {
 | 
			
		||||
        monitor_printf(mon, "%s", info->device);
 | 
			
		||||
        if (inserted && inserted->has_node_name) {
 | 
			
		||||
            monitor_printf(mon, " (%s)", inserted->node_name);
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        assert(inserted);
 | 
			
		||||
        monitor_printf(mon, "%s",
 | 
			
		||||
                       inserted->has_node_name
 | 
			
		||||
                       ? inserted->node_name
 | 
			
		||||
                       : "<anonymous>");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (inserted) {
 | 
			
		||||
        monitor_printf(mon, ": %s (%s%s%s)\n",
 | 
			
		||||
                       inserted->file,
 | 
			
		||||
| 
						 | 
				
			
			@ -306,6 +320,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
 | 
			
		|||
        monitor_printf(mon, ": [not inserted]\n");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (info) {
 | 
			
		||||
        if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
 | 
			
		||||
            monitor_printf(mon, "    I/O status:       %s\n",
 | 
			
		||||
                           BlockDeviceIoStatus_lookup[info->io_status]);
 | 
			
		||||
| 
						 | 
				
			
			@ -316,6 +331,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
 | 
			
		|||
                           info->locked ? "" : "not ",
 | 
			
		||||
                           info->tray_open ? "open" : "closed");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if (!inserted) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue