Skip to content

Commit

Permalink
ipmi: Add a UUID device property
Browse files Browse the repository at this point in the history
Using the UUID that qemu generates probably isn't the best thing
to do, allow it to be passed in via properties, and use QemuUUID
for the type.

If the UUID is not set, return an unsupported command error.  This
way we are not providing an all-zero (or randomly generated) GUID
to the IPMI user.  This lets the host fall back to the other
method of using the get device id command to determind the BMC
being accessed.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Cédric Le Goater <clg@kaod.org>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
cminyard committed Sep 20, 2019
1 parent a65f4d4 commit 7b0cd78
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
22 changes: 14 additions & 8 deletions hw/ipmi/ipmi_bmc_sim.c
Expand Up @@ -223,7 +223,7 @@ struct IPMIBmcSim {
uint8_t restart_cause;

uint8_t acpi_power_state[2];
uint8_t uuid[16];
QemuUUID uuid;

IPMISel sel;
IPMISdr sdr;
Expand Down Expand Up @@ -941,8 +941,19 @@ static void get_device_guid(IPMIBmcSim *ibs,
{
unsigned int i;

/* An uninitialized uuid is all zeros, use that to know if it is set. */
for (i = 0; i < 16; i++) {
rsp_buffer_push(rsp, ibs->uuid[i]);
if (ibs->uuid.data[i]) {
goto uuid_set;
}
}
/* No uuid is set, return an error. */
rsp_buffer_set_error(rsp, IPMI_CC_INVALID_CMD);
return;

uuid_set:
for (i = 0; i < 16; i++) {
rsp_buffer_push(rsp, ibs->uuid.data[i]);
}
}

Expand Down Expand Up @@ -1986,12 +1997,6 @@ static void ipmi_sim_realize(DeviceState *dev, Error **errp)
ibs->acpi_power_state[0] = 0;
ibs->acpi_power_state[1] = 0;

if (qemu_uuid_set) {
memcpy(&ibs->uuid, &qemu_uuid, 16);
} else {
memset(&ibs->uuid, 0, 16);
}

ipmi_init_sensors_from_sdrs(ibs);
register_cmds(ibs);

Expand All @@ -2011,6 +2016,7 @@ static Property ipmi_sim_properties[] = {
DEFINE_PROP_UINT8("fwrev2", IPMIBmcSim, fwrev2, 0),
DEFINE_PROP_UINT32("mfg_id", IPMIBmcSim, mfg_id, 0),
DEFINE_PROP_UINT16("product_id", IPMIBmcSim, product_id, 0),
DEFINE_PROP_UUID_NODEFAULT("guid", IPMIBmcSim, uuid),
DEFINE_PROP_END_OF_LIST(),
};

Expand Down
10 changes: 7 additions & 3 deletions qemu-options.hx
Expand Up @@ -701,7 +701,7 @@ possible drivers and properties, use @code{-device help} and
@code{-device @var{driver},help}.

Some drivers are:
@item -device ipmi-bmc-sim,id=@var{id}[,slave_addr=@var{val}][,sdrfile=@var{file}][,furareasize=@var{val}][,furdatafile=@var{file}]
@item -device ipmi-bmc-sim,id=@var{id}[,slave_addr=@var{val}][,sdrfile=@var{file}][,furareasize=@var{val}][,furdatafile=@var{file}][,guid=@var{uuid}]

Add an IPMI BMC. This is a simulation of a hardware management
interface processor that normally sits on a system. It provides
Expand All @@ -714,8 +714,8 @@ controllers. If you don't know what this means, it is safe to ignore
it.

@table @option
@item bmc=@var{id}
The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above.
@item id=@var{id}
The BMC id for interfaces to use this device.
@item slave_addr=@var{val}
Define slave address to use for the BMC. The default is 0x20.
@item sdrfile=@var{file}
Expand All @@ -724,6 +724,10 @@ file containing raw Sensor Data Records (SDR) data. The default is none.
size of a Field Replaceable Unit (FRU) area. The default is 1024.
@item frudatafile=@var{file}
file containing raw Field Replaceable Unit (FRU) inventory data. The default is none.
@item guid=@var{uuid}
value for the GUID for the BMC, in standard UUID format. If this is set,
get "Get GUID" command to the BMC will return it. Otherwise "Get GUID"
will return an error.
@end table

@item -device ipmi-bmc-extern,id=@var{id},chardev=@var{id}[,slave_addr=@var{val}]
Expand Down

0 comments on commit 7b0cd78

Please sign in to comment.