pc-dimm: Add Error argument to pc_existing_dimms_capacity
Now that pc_existing_dimms_capacity() is an API, include Error pointer as an argument and modify the caller appropriately. Suggested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
This commit is contained in:
		
							parent
							
								
									9967c94957
								
							
						
					
					
						commit
						3715345043
					
				@ -1584,8 +1584,8 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
 | 
				
			|||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pc_existing_dimms_capacity(OBJECT(machine), &existing_dimms_capacity)) {
 | 
					    existing_dimms_capacity = pc_existing_dimms_capacity(&local_err);
 | 
				
			||||||
        error_setg(&local_err, "failed to get total size of existing DIMMs");
 | 
					    if (local_err) {
 | 
				
			||||||
        goto out;
 | 
					        goto out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -22,32 +22,44 @@
 | 
				
			|||||||
#include "qemu/config-file.h"
 | 
					#include "qemu/config-file.h"
 | 
				
			||||||
#include "qapi/visitor.h"
 | 
					#include "qapi/visitor.h"
 | 
				
			||||||
#include "qemu/range.h"
 | 
					#include "qemu/range.h"
 | 
				
			||||||
#include "qapi/qmp/qerror.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int pc_existing_dimms_capacity(Object *obj, void *opaque)
 | 
					typedef struct pc_dimms_capacity {
 | 
				
			||||||
 | 
					     uint64_t size;
 | 
				
			||||||
 | 
					     Error    **errp;
 | 
				
			||||||
 | 
					} pc_dimms_capacity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int pc_existing_dimms_capacity_internal(Object *obj, void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Error *local_err = NULL;
 | 
					    pc_dimms_capacity *cap = opaque;
 | 
				
			||||||
    uint64_t *size = opaque;
 | 
					    uint64_t *size = &cap->size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
 | 
					    if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
 | 
				
			||||||
        DeviceState *dev = DEVICE(obj);
 | 
					        DeviceState *dev = DEVICE(obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (dev->realized) {
 | 
					        if (dev->realized) {
 | 
				
			||||||
            (*size) += object_property_get_int(obj, PC_DIMM_SIZE_PROP,
 | 
					            (*size) += object_property_get_int(obj, PC_DIMM_SIZE_PROP,
 | 
				
			||||||
                &local_err);
 | 
					                cap->errp);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (local_err) {
 | 
					        if (cap->errp && *cap->errp) {
 | 
				
			||||||
            qerror_report_err(local_err);
 | 
					 | 
				
			||||||
            error_free(local_err);
 | 
					 | 
				
			||||||
            return 1;
 | 
					            return 1;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    object_child_foreach(obj, pc_existing_dimms_capacity_internal, opaque);
 | 
				
			||||||
    object_child_foreach(obj, pc_existing_dimms_capacity, opaque);
 | 
					 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint64_t pc_existing_dimms_capacity(Error **errp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    pc_dimms_capacity cap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cap.size = 0;
 | 
				
			||||||
 | 
					    cap.errp = errp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pc_existing_dimms_capacity_internal(qdev_get_machine(), &cap);
 | 
				
			||||||
 | 
					    return cap.size;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 | 
					int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    MemoryDeviceInfoList ***prev = opaque;
 | 
					    MemoryDeviceInfoList ***prev = opaque;
 | 
				
			||||||
 | 
				
			|||||||
@ -78,5 +78,5 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
 | 
				
			|||||||
int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
 | 
					int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int qmp_pc_dimm_device_list(Object *obj, void *opaque);
 | 
					int qmp_pc_dimm_device_list(Object *obj, void *opaque);
 | 
				
			||||||
int pc_existing_dimms_capacity(Object *obj, void *opaque);
 | 
					uint64_t pc_existing_dimms_capacity(Error **errp);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user