machine: Fix replacement of '_' by '-' in machine property names
machine_set_property() replaces '_' by '-' in the property name. Except it fails to replace an initial '_'. Screwed up in commit b0ddb8b. Reproducer: "-M pc,__foo_bar=true" produces "Property '._-foo-bar' not found". Error messages using a mangled name rather than the name the user actually wrote is user-hostile, but that's a different topic. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
		
							parent
							
								
									0975b8b823
								
							
						
					
					
						commit
						f279ee4583
					
				
							
								
								
									
										9
									
								
								vl.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								vl.c
									
									
									
									
									
								
							@ -2804,17 +2804,16 @@ static int machine_set_property(void *opaque,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    Object *obj = OBJECT(opaque);
 | 
					    Object *obj = OBJECT(opaque);
 | 
				
			||||||
    Error *local_err = NULL;
 | 
					    Error *local_err = NULL;
 | 
				
			||||||
    char *c, *qom_name;
 | 
					    char *p, *qom_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (strcmp(name, "type") == 0) {
 | 
					    if (strcmp(name, "type") == 0) {
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qom_name = g_strdup(name);
 | 
					    qom_name = g_strdup(name);
 | 
				
			||||||
    c = qom_name;
 | 
					    for (p = qom_name; *p; p++) {
 | 
				
			||||||
    while (*c++) {
 | 
					        if (*p == '_') {
 | 
				
			||||||
        if (*c == '_') {
 | 
					            *p = '-';
 | 
				
			||||||
            *c = '-';
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user