qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
@ 2025-06-27 17:13 Yunpeng Yang
  2025-08-03 11:15 ` Yunpeng Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Yunpeng Yang @ 2025-06-27 17:13 UTC (permalink / raw)
  To: minyard@acm.org; +Cc: qemu-devel@nongnu.org, Mark Cave-Ayland, Jonathan Davies


[-- Attachment #1.1: Type: text/plain, Size: 1187 bytes --]

Hello Corey Minyard,

I hope this email finds you well.

I'm currently adding LAN-configs-retrieval support to the QEMU ipmi-bmc-sim device. And I hope to merge the modifications upstream after it's finished. Could you please check the attached patch file of the draft code and share your opinions and advice?

In my work, we need to run tools like "ipmitool lan print" on a VM for testing purposes. However, QEMU internal BMC simulator device (`ipmi-bmc-sim`) does not support retrieving LAN configs from it. I have to implement two IPMI commands so that the device can now work with ipmitool. The LAN config values are faked, but for testing purposes this is not a problem. I believe other people may also have the same need, so it's worth getting merged upstream.

The fake BMC LAN config values are currently hard coded into the code. My plan is to add a parameter to the device, which is a file containing user designated values. The device then reads the file and returns those values as LAN configs. This is similar to sdrfile for sensor data and frudatafile for FRU data.

Looking forward to hearing your thoughts.
Have a nice weekend.

Kind regards,
Yunpeng Yang

[-- Attachment #1.2: Type: text/html, Size: 4652 bytes --]

[-- Attachment #2: 0001-hw-ipmi-ipmi_bmc_sim.c-generating-fake-LAN-channel-i.patch --]
[-- Type: application/octet-stream, Size: 10007 bytes --]

From a8658d0c6028c9bd978d43e843fff4c8abd387a5 Mon Sep 17 00:00:00 2001
From: Yunpeng Yang <yunpeng.yang@nutanix.com>
Date: Wed, 11 Jun 2025 11:40:25 +0000
Subject: [PATCH] hw/ipmi/ipmi_bmc_sim.c: generating fake LAN channel info

Add partial support for two IPMI commands, "Get Channel Info Command"
and "Get LAN Configuration Parameters Command", to the qemu
`ipmi_bmc_sim` device. Fake BMC LAN channel info will be generated for
these two commands.

`ipmitool lan print` can now be run on a qemu VM to retrieve the fake
BMC LAN info if `ipmi_bmc_sim` is enabled.

IPMI2.0 interface specification:
https://www.intel.com/content/www/us/en/products/docs/servers/
ipmi/ipmi-second-gen-interface-spec-v2-rev1-1.html

Change-Id: Ia841c6f996d7a1d85ad35128b99790397bd40d7c
---
 hw/ipmi/ipmi_bmc_sim.c | 181 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 181 insertions(+)

diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 905e091094..dacebb9d78 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -70,6 +70,7 @@
 #define IPMI_CMD_GET_MSG                  0x33
 #define IPMI_CMD_SEND_MSG                 0x34
 #define IPMI_CMD_READ_EVT_MSG_BUF         0x35
+#define IPMI_CMD_GET_CHANNEL_INFO         0x42
 
 #define IPMI_NETFN_STORAGE            0x0a
 
@@ -100,6 +101,10 @@
 #define IPMI_CMD_GET_SEL_TIME             0x48
 #define IPMI_CMD_SET_SEL_TIME             0x49
 
+#define IPMI_NETFN_TRANSPORT          0x0c
+
+#define IPMI_CMD_GET_LAN_CONFIG           0x02
+
 
 /* Same as a timespec struct. */
 struct ipmi_time {
@@ -263,6 +268,28 @@ struct IPMIBmcSim {
 #define IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN      2
 #define IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE     3
 
+/*
+ * Refer to the IPMI2.0 interface specification:
+ * https://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/
+ *     ipmi-second-gen-interface-spec-v2-rev1-1.pdf
+ */
+#define IPMI_BMC_LAN_CFG_PARAMETER_REVISION        0x11
+#define IPMI_BMC_LAN_CFG_CC_PARAM_NOT_SUPPORTED    0x80
+#define IPMI_BMC_LAN_CFG_PARAM_SET_IN_PROGRESS          0x00
+#define IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_SUPPORT        0x01
+#define IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_ENABLES        0x02
+#define IPMI_BMC_LAN_CFG_PARAM_IP_ADDR                  0x03
+#define IPMI_BMC_LAN_CFG_PARAM_IP_ADDR_SOURCE           0x04
+#define IPMI_BMC_LAN_CFG_PARAM_MAC_ADDR                 0x05
+#define IPMI_BMC_LAN_CFG_PARAM_SUBNET_MASK              0x06
+#define IPMI_BMC_LAN_CFG_PARAM_IPV4_HDR_PARAM           0x07
+#define IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_ADDR          0x0c
+#define IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_MAC_ADDR      0x0d
+#define IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_ADDR           0x0e
+#define IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_MAC_ADDR       0x0f
+#define IPMI_BMC_LAN_CFG_PARAM_COMMUNITY_STRING         0x10
+#define IPMI_BMC_LAN_CFG_PARAM_NUM_DESTINATIONS         0x11
+
 #define RSP_BUFFER_INITIALIZER { }
 
 static inline void rsp_buffer_pushmore(RspBuffer *rsp, uint8_t *bytes,
@@ -1219,6 +1246,37 @@ static void get_watchdog_timer(IPMIBmcSim *ibs,
     }
 }
 
+/*
+ * TODO: Add a `chnlfile=` parameter to the `ipmi_bmc_sim` device.
+ * Use that file to specify the channel info.
+ * If a channel is a LAN channel, include LAN parameters in that file.
+ */
+static void get_channel_info(IPMIBmcSim *ibs,
+                             uint8_t *cmd, unsigned int cmd_len,
+                             RspBuffer *rsp)
+{
+    uint8_t channel = cmd[2] & 0xf;
+    /* Refer to IPMI protocol for channel number assignments */
+    switch (channel) {
+    case 1:
+        rsp_buffer_push(rsp, 1); /* Actual channel number */
+        rsp_buffer_push(rsp, 0x4); /* Channel medium type: 802.3 LAN */
+        rsp_buffer_push(rsp, 0x0); /* Channel protocol: type n/a */
+        rsp_buffer_push(rsp, 0x0); /* Session support: session less */
+        /* 3-byte Vendor ID: IPMI Enterprise Number 7154 (LSB first) */
+        rsp_buffer_push(rsp, 0xf2);
+        rsp_buffer_push(rsp, 0x1b);
+        rsp_buffer_push(rsp, 0x00);
+        /* 2-byte Auxiliary Channel Info */
+        rsp_buffer_push(rsp, 0x0);
+        rsp_buffer_push(rsp, 0x0);
+        break;
+    default:
+        rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD);
+        break;
+    }
+}
+
 static void get_sdr_rep_info(IPMIBmcSim *ibs,
                              uint8_t *cmd, unsigned int cmd_len,
                              RspBuffer *rsp)
@@ -1971,6 +2029,118 @@ static void set_sensor_reading(IPMIBmcSim *ibs,
     }
 }
 
+/*
+ * bytes   parameter
+ *    1    [7] revision only flag, [3:0] channel number
+ *    2    parameter selector
+ *    3    set selector
+ *    4    block selector
+ */
+static void get_lan_config(IPMIBmcSim *ibs,
+                            uint8_t *cmd, unsigned int cmd_len,
+                            RspBuffer *rsp)
+{
+    rsp_buffer_push(rsp, IPMI_BMC_LAN_CFG_PARAMETER_REVISION);
+    /* The requester only requests parameter revision, not the parameter */
+    if (cmd[2] & 0x80) {
+        return;
+    }
+
+    switch (cmd[3]) {
+    case IPMI_BMC_LAN_CFG_PARAM_SET_IN_PROGRESS:
+        rsp_buffer_push(rsp, 0x00); /* set complete */
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_SUPPORT:
+        rsp_buffer_push(rsp, 0x01); /* Authentication type "none" supported */
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_ENABLES:
+        /* Only authentication type "none" enabled */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "Callback" */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "User" */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "Operator" */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "Administrator" */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "OEM" */
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_IP_ADDR:
+        /* 192.0.2.1 */
+        rsp_buffer_push(rsp, 0xc0);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x02);
+        rsp_buffer_push(rsp, 0x01);
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_IP_ADDR_SOURCE:
+        rsp_buffer_push(rsp, 0x00); /* unspecified address source */
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_MAC_ADDR:
+        /* 02:00:00:00:00:01 */
+        rsp_buffer_push(rsp, 0x02);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x01);
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_SUBNET_MASK:
+        /* 255.255.255.0 */
+        rsp_buffer_push(rsp, 0xff);
+        rsp_buffer_push(rsp, 0xff);
+        rsp_buffer_push(rsp, 0xff);
+        rsp_buffer_push(rsp, 0x00);
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_IPV4_HDR_PARAM:
+        rsp_buffer_push(rsp, 0x40);
+        rsp_buffer_push(rsp, 0x40);
+        rsp_buffer_push(rsp, 0x10);
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_ADDR:
+        /* 192.0.2.1 */
+        rsp_buffer_push(rsp, 0xc0);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x02);
+        rsp_buffer_push(rsp, 0x01);
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_MAC_ADDR:
+        /* 02:00:00:00:00:01 */
+        rsp_buffer_push(rsp, 0x02);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x01);
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_ADDR:
+        /* 0.0.0.0 */
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_MAC_ADDR:
+        /* 00:00:00:00:00:00 */
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_COMMUNITY_STRING:
+        {
+            /* Better for `community_str` to be const,
+             * but `rsp_buffer_pushmore` requires non-const */
+            static uint8_t community_str[18] = "public";
+            rsp_buffer_pushmore(rsp, community_str, sizeof(community_str));
+        }
+        break;
+    case IPMI_BMC_LAN_CFG_PARAM_NUM_DESTINATIONS:
+        rsp_buffer_push(rsp, 0x00); /* LAN Alerting not supported */
+        break;
+    default :
+        rsp_buffer_set_error(rsp, IPMI_BMC_LAN_CFG_CC_PARAM_NOT_SUPPORTED);
+        return;
+    };
+}
+
 static const IPMICmdHandler chassis_cmds[] = {
     [IPMI_CMD_GET_CHASSIS_CAPABILITIES] = { chassis_capabilities },
     [IPMI_CMD_GET_CHASSIS_STATUS] = { chassis_status },
@@ -2015,6 +2185,7 @@ static const IPMICmdHandler app_cmds[] = {
     [IPMI_CMD_RESET_WATCHDOG_TIMER] = { reset_watchdog_timer },
     [IPMI_CMD_SET_WATCHDOG_TIMER] = { set_watchdog_timer, 8 },
     [IPMI_CMD_GET_WATCHDOG_TIMER] = { get_watchdog_timer },
+    [IPMI_CMD_GET_CHANNEL_INFO] = { get_channel_info, 3 },
 };
 static const IPMINetfn app_netfn = {
     .cmd_nums = ARRAY_SIZE(app_cmds),
@@ -2044,12 +2215,22 @@ static const IPMINetfn storage_netfn = {
     .cmd_handlers = storage_cmds
 };
 
+static const IPMICmdHandler transport_cmds[] = {
+    [IPMI_CMD_GET_LAN_CONFIG] = { get_lan_config, 6 }
+};
+static const IPMINetfn transport_netfn = {
+    .cmd_nums = ARRAY_SIZE(transport_cmds),
+    .cmd_handlers = transport_cmds
+};
+
+
 static void register_cmds(IPMIBmcSim *s)
 {
     ipmi_sim_register_netfn(s, IPMI_NETFN_CHASSIS, &chassis_netfn);
     ipmi_sim_register_netfn(s, IPMI_NETFN_SENSOR_EVENT, &sensor_event_netfn);
     ipmi_sim_register_netfn(s, IPMI_NETFN_APP, &app_netfn);
     ipmi_sim_register_netfn(s, IPMI_NETFN_STORAGE, &storage_netfn);
+    ipmi_sim_register_netfn(s, IPMI_NETFN_TRANSPORT, &transport_netfn);
 }
 
 static uint8_t init_sdrs[] = {
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
  2025-06-27 17:13 Add support for retrieving fake LAN config from `ipmi-bmc-sim` device Yunpeng Yang
@ 2025-08-03 11:15 ` Yunpeng Yang
  2025-08-03 13:22   ` Corey Minyard
  0 siblings, 1 reply; 7+ messages in thread
From: Yunpeng Yang @ 2025-08-03 11:15 UTC (permalink / raw)
  To: minyard@acm.org; +Cc: qemu-devel@nongnu.org, Mark Cave-Ayland, Jonathan Davies

[-- Attachment #1: Type: text/plain, Size: 2152 bytes --]

Hello Corey Minyard,

I hope you are all well.

Could I ask for your opinion on whether it is worthing implementing a fake LAN config for device ipmi-bmc-sim ? (Details are in my last email, which is also included below).

During my work over last month, I found that QEMU already has ipmi-bmc-extern which supports comprehensive BMC simulation, including LAN config faking. But ipmi-bmc-sim is more light-weight and easier to set up. So I think it still has some value in implementing LAN config for ipmi-bmc-sim . Could you please share your views?

Best regards,
Yunpeng Yang


________________________________
From: Yunpeng Yang <yunpeng.yang@nutanix.com>
Sent: Friday, June 27, 2025 18:13
To: minyard@acm.org <minyard@acm.org>
Cc: qemu-devel@nongnu.org <qemu-devel@nongnu.org>; Mark Cave-Ayland <mark.caveayland@nutanix.com>; Jonathan Davies <jond@nutanix.com>
Subject: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device

Hello Corey Minyard,

I hope this email finds you well.

I'm currently adding LAN-configs-retrieval support to the QEMU ipmi-bmc-sim device. And I hope to merge the modifications upstream after it's finished. Could you please check the attached patch file of the draft code and share your opinions and advice?

In my work, we need to run tools like "ipmitool lan print" on a VM for testing purposes. However, QEMU internal BMC simulator device (`ipmi-bmc-sim`) does not support retrieving LAN configs from it. I have to implement two IPMI commands so that the device can now work with ipmitool. The LAN config values are faked, but for testing purposes this is not a problem. I believe other people may also have the same need, so it's worth getting merged upstream.

The fake BMC LAN config values are currently hard coded into the code. My plan is to add a parameter to the device, which is a file containing user designated values. The device then reads the file and returns those values as LAN configs. This is similar to sdrfile for sensor data and frudatafile for FRU data.

Looking forward to hearing your thoughts.
Have a nice weekend.

Kind regards,
Yunpeng Yang

[-- Attachment #2: Type: text/html, Size: 7905 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
  2025-08-03 11:15 ` Yunpeng Yang
@ 2025-08-03 13:22   ` Corey Minyard
  2025-08-04 12:08     ` Yunpeng Yang
  2025-10-14 12:19     ` Yunpeng Yang
  0 siblings, 2 replies; 7+ messages in thread
From: Corey Minyard @ 2025-08-03 13:22 UTC (permalink / raw)
  To: Yunpeng Yang
  Cc: minyard@acm.org, qemu-devel@nongnu.org, Mark Cave-Ayland,
	Jonathan Davies

[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]

On Sun, Aug 3, 2025 at 6:16 AM Yunpeng Yang <yunpeng.yang@nutanix.com>
wrote:

> Hello Corey Minyard,
>
> I hope you are all well.
>
> Could I ask for your opinion on whether it is worthing implementing a fake
> LAN config for device ipmi-bmc-sim ? (Details are in my last email, which
> is also included below).
>
> During my work over last month, I found that QEMU already has
> ipmi-bmc-extern which supports comprehensive BMC simulation, including
> LAN config faking. But ipmi-bmc-sim is more light-weight and easier to
> set up. So I think it still has some value in implementing LAN config for
> ipmi-bmc-sim . Could you please share your views?
>
>
Well, there is no LAN interface, so I didn't see any need to add that.  The
values would not be permanent.  But it would be harmless to add, so I'd be
ok with a patch to do this.

The external interface with ipmisim from the OpenIPMI library provides a
pretty comprehensive solution.

-corey


> Best regards,
> Yunpeng Yang
>
>
> ------------------------------
> *From:* Yunpeng Yang <yunpeng.yang@nutanix.com>
> *Sent:* Friday, June 27, 2025 18:13
> *To:* minyard@acm.org <minyard@acm.org>
> *Cc:* qemu-devel@nongnu.org <qemu-devel@nongnu.org>; Mark Cave-Ayland <
> mark.caveayland@nutanix.com>; Jonathan Davies <jond@nutanix.com>
> *Subject:* Add support for retrieving fake LAN config from `ipmi-bmc-sim`
> device
>
> Hello Corey Minyard,
>
> I hope this email finds you well.
>
> I'm currently adding LAN-configs-retrieval support to the QEMU
> ipmi-bmc-sim device. And I hope to merge the modifications upstream after
> it's finished. Could you please check the attached patch file of the draft
> code and share your opinions and advice?
>
> In my work, we need to run tools like "ipmitool lan print" on a VM for
> testing purposes. However, QEMU internal BMC simulator device
> (`ipmi-bmc-sim`) does not support retrieving LAN configs from it. I have to
> implement two IPMI commands so that the device can now work with ipmitool.
> The LAN config values are faked, but for testing purposes this is not a
> problem. I believe other people may also have the same need, so it's worth
> getting merged upstream.
>
> The fake BMC LAN config values are currently hard coded into the code. My
> plan is to add a parameter to the device, which is a file containing user
> designated values. The device then reads the file and returns those values
> as LAN configs. This is similar to sdrfile for sensor data and frudatafile for
> FRU data.
>
> Looking forward to hearing your thoughts.
> Have a nice weekend.
>
> Kind regards,
> Yunpeng Yang
>

[-- Attachment #2: Type: text/html, Size: 8572 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
  2025-08-03 13:22   ` Corey Minyard
@ 2025-08-04 12:08     ` Yunpeng Yang
  2025-10-14 12:19     ` Yunpeng Yang
  1 sibling, 0 replies; 7+ messages in thread
From: Yunpeng Yang @ 2025-08-04 12:08 UTC (permalink / raw)
  To: Corey Minyard
  Cc: minyard@acm.org, qemu-devel@nongnu.org, Mark Cave-Ayland,
	Jonathan Davies

[-- Attachment #1: Type: text/plain, Size: 3414 bytes --]

Hello Corey,

Glad to hear back from you and have your opinion. Thank you.

I'll later send you a patch for your review. I probably need some days to make it ready.

Kind regards,
Yunpeng Yang


________________________________
From: Corey Minyard <corey@minyard.net>
Sent: Sunday, August 03, 2025 14:22
To: Yunpeng Yang <yunpeng.yang@nutanix.com>
Cc: minyard@acm.org <minyard@acm.org>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>; Mark Cave-Ayland <mark.caveayland@nutanix.com>; Jonathan Davies <jond@nutanix.com>
Subject: Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device

CAUTION: External Email

On Sun, Aug 3, 2025 at 6:16 AM Yunpeng Yang <yunpeng.yang@nutanix.com<mailto:yunpeng.yang@nutanix.com>> wrote:
Hello Corey Minyard,

I hope you are all well.

Could I ask for your opinion on whether it is worthing implementing a fake LAN config for device ipmi-bmc-sim ? (Details are in my last email, which is also included below).

During my work over last month, I found that QEMU already has ipmi-bmc-extern which supports comprehensive BMC simulation, including LAN config faking. But ipmi-bmc-sim is more light-weight and easier to set up. So I think it still has some value in implementing LAN config for ipmi-bmc-sim . Could you please share your views?


Well, there is no LAN interface, so I didn't see any need to add that.  The values would not be permanent.  But it would be harmless to add, so I'd be ok with a patch to do this.

The external interface with ipmisim from the OpenIPMI library provides a pretty comprehensive solution.

-corey

Best regards,
Yunpeng Yang


________________________________
From: Yunpeng Yang <yunpeng.yang@nutanix.com<mailto:yunpeng.yang@nutanix.com>>
Sent: Friday, June 27, 2025 18:13
To: minyard@acm.org<mailto:minyard@acm.org> <minyard@acm.org<mailto:minyard@acm.org>>
Cc: qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org> <qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org>>; Mark Cave-Ayland <mark.caveayland@nutanix.com<mailto:mark.caveayland@nutanix.com>>; Jonathan Davies <jond@nutanix.com<mailto:jond@nutanix.com>>
Subject: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device

Hello Corey Minyard,

I hope this email finds you well.

I'm currently adding LAN-configs-retrieval support to the QEMU ipmi-bmc-sim device. And I hope to merge the modifications upstream after it's finished. Could you please check the attached patch file of the draft code and share your opinions and advice?

In my work, we need to run tools like "ipmitool lan print" on a VM for testing purposes. However, QEMU internal BMC simulator device (`ipmi-bmc-sim`) does not support retrieving LAN configs from it. I have to implement two IPMI commands so that the device can now work with ipmitool. The LAN config values are faked, but for testing purposes this is not a problem. I believe other people may also have the same need, so it's worth getting merged upstream.

The fake BMC LAN config values are currently hard coded into the code. My plan is to add a parameter to the device, which is a file containing user designated values. The device then reads the file and returns those values as LAN configs. This is similar to sdrfile for sensor data and frudatafile for FRU data.

Looking forward to hearing your thoughts.
Have a nice weekend.

Kind regards,
Yunpeng Yang

[-- Attachment #2: Type: text/html, Size: 13298 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
  2025-08-03 13:22   ` Corey Minyard
  2025-08-04 12:08     ` Yunpeng Yang
@ 2025-10-14 12:19     ` Yunpeng Yang
  2025-10-14 23:17       ` Corey Minyard
  1 sibling, 1 reply; 7+ messages in thread
From: Yunpeng Yang @ 2025-10-14 12:19 UTC (permalink / raw)
  To: Corey Minyard
  Cc: minyard@acm.org, qemu-devel@nongnu.org, Mark Cave-Ayland,
	Jonathan Davies


[-- Attachment #1.1: Type: text/plain, Size: 4044 bytes --]

Hello Corey,

I hope you are all well.

I've finally come up with a patch for implementing the fake LAN configurations for the device ipmi-bmc-sim. My apologies for the long long delay. And thank you for your patience.

Please find attached the patch file. The patch is base on commit: bd6aa0d1e5 ("Merge tag 'staging-pull-request' of https://gitlab.com/peterx/qemu into staging"). Could you please review the patch and let me know your opinions?

Looking forward to hearing back from you.

Kind regards,
Yunpeng Yang



________________________________
From: Corey Minyard <corey@minyard.net>
Sent: Sunday, August 03, 2025 14:22
To: Yunpeng Yang <yunpeng.yang@nutanix.com>
Cc: minyard@acm.org <minyard@acm.org>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>; Mark Cave-Ayland <mark.caveayland@nutanix.com>; Jonathan Davies <jond@nutanix.com>
Subject: Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device

On Sun, Aug 3, 2025 at 6: 16 AM Yunpeng Yang <yunpeng. yang@ nutanix. com> wrote: Hello Corey Minyard, I hope you are all well. Could I ask for your opinion on whether it is worthing implementing a fake LAN config for device ipmi-bmc-sim ?
ZjQcmQRYFpfptBannerStart
CAUTION: External Email

ZjQcmQRYFpfptBannerEnd
On Sun, Aug 3, 2025 at 6:16 AM Yunpeng Yang <yunpeng.yang@nutanix.com<mailto:yunpeng.yang@nutanix.com>> wrote:
Hello Corey Minyard,

I hope you are all well.

Could I ask for your opinion on whether it is worthing implementing a fake LAN config for device ipmi-bmc-sim ? (Details are in my last email, which is also included below).

During my work over last month, I found that QEMU already has ipmi-bmc-extern which supports comprehensive BMC simulation, including LAN config faking. But ipmi-bmc-sim is more light-weight and easier to set up. So I think it still has some value in implementing LAN config for ipmi-bmc-sim . Could you please share your views?


Well, there is no LAN interface, so I didn't see any need to add that.  The values would not be permanent.  But it would be harmless to add, so I'd be ok with a patch to do this.

The external interface with ipmisim from the OpenIPMI library provides a pretty comprehensive solution.

-corey

Best regards,
Yunpeng Yang


________________________________
From: Yunpeng Yang <yunpeng.yang@nutanix.com<mailto:yunpeng.yang@nutanix.com>>
Sent: Friday, June 27, 2025 18:13
To: minyard@acm.org<mailto:minyard@acm.org> <minyard@acm.org<mailto:minyard@acm.org>>
Cc: qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org> <qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org>>; Mark Cave-Ayland <mark.caveayland@nutanix.com<mailto:mark.caveayland@nutanix.com>>; Jonathan Davies <jond@nutanix.com<mailto:jond@nutanix.com>>
Subject: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device

Hello Corey Minyard,

I hope this email finds you well.

I'm currently adding LAN-configs-retrieval support to the QEMU ipmi-bmc-sim device. And I hope to merge the modifications upstream after it's finished. Could you please check the attached patch file of the draft code and share your opinions and advice?

In my work, we need to run tools like "ipmitool lan print" on a VM for testing purposes. However, QEMU internal BMC simulator device (`ipmi-bmc-sim`) does not support retrieving LAN configs from it. I have to implement two IPMI commands so that the device can now work with ipmitool. The LAN config values are faked, but for testing purposes this is not a problem. I believe other people may also have the same need, so it's worth getting merged upstream.

The fake BMC LAN config values are currently hard coded into the code. My plan is to add a parameter to the device, which is a file containing user designated values. The device then reads the file and returns those values as LAN configs. This is similar to sdrfile for sensor data and frudatafile for FRU data.

Looking forward to hearing your thoughts.
Have a nice weekend.

Kind regards,
Yunpeng Yang

[-- Attachment #1.2: Type: text/html, Size: 14320 bytes --]

[-- Attachment #2: 0001-hw-ipmi-ipmi_bmc_sim-Support-fake-LAN-channel.patch --]
[-- Type: application/octet-stream, Size: 25525 bytes --]

From 9069451ecfa32077cc19f370fe78a4a539508d7d Mon Sep 17 00:00:00 2001
From: Yunpeng Yang <yunpeng.yang@nutanix.com>
Date: Wed, 11 Jun 2025 11:40:25 +0000
Subject: [PATCH] hw/ipmi/ipmi_bmc_sim: Support fake LAN channel

The following IPMI commands are added or modified to support a fake LAN
channel in `ipmi_bmc_sim` device:
* Get Channel Access;
* Get Channel Info Command;
* Set LAN Configuration Parameters;
* Get LAN Configuration Parameters.
The LAN channel supports setting and getting certain LAN information.

With the fake LAN channel enabled, `ipmi_bmc_sim` can now interact with
some IPMI tools, e.g., `ipmitool lan print`.

Change-Id: Iec286e4bcac84b6deb6ff551df7d929ded215c03
Signed-off-by: Yunpeng Yang <yunpeng.yang@nutanix.com>
---
 hw/ipmi/ipmi_bmc_sim.c      | 373 +++++++++++++++++++++++++++++++++++-
 include/hw/ipmi/ipmi.h      |   1 +
 tests/qtest/ipmi-kcs-test.c | 124 +++++++++++-
 3 files changed, 487 insertions(+), 11 deletions(-)

diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 04e1dcd0e7..370106374d 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -27,11 +27,13 @@
 #include "qemu/timer.h"
 #include "hw/ipmi/ipmi.h"
 #include "qemu/error-report.h"
+#include "qapi/error.h"
 #include "qemu/module.h"
 #include "hw/loader.h"
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "migration/vmstate.h"
+#include "net/net.h"
 
 #define IPMI_NETFN_CHASSIS            0x00
 
@@ -70,6 +72,7 @@
 #define IPMI_CMD_GET_MSG                  0x33
 #define IPMI_CMD_SEND_MSG                 0x34
 #define IPMI_CMD_READ_EVT_MSG_BUF         0x35
+#define IPMI_CMD_GET_CHANNEL_ACCESS       0x41
 #define IPMI_CMD_GET_CHANNEL_INFO         0x42
 
 #define IPMI_NETFN_STORAGE            0x0a
@@ -101,6 +104,11 @@
 #define IPMI_CMD_GET_SEL_TIME             0x48
 #define IPMI_CMD_SET_SEL_TIME             0x49
 
+#define IPMI_NETFN_TRANSPORT          0x0c
+
+#define IPMI_CMD_SET_LAN_CONFIG           0x01
+#define IPMI_CMD_GET_LAN_CONFIG           0x02
+
 
 /* Same as a timespec struct. */
 struct ipmi_time {
@@ -170,6 +178,23 @@ typedef struct IPMISensor {
 #define MAX_SENSORS 20
 #define IPMI_WATCHDOG_SENSOR 0
 
+#define NBYTES_IP  4
+#define NBYTES_MAC 6
+
+typedef struct IPMILan {
+    uint8_t channel;
+    uint8_t ipaddr[NBYTES_IP];
+    uint8_t ipsrc;
+    MACAddr macaddr;
+    uint8_t netmask[NBYTES_IP];
+    uint8_t defgw_ipaddr[NBYTES_IP];
+    MACAddr defgw_macaddr;
+
+    char *arg_ipaddr;
+    char *arg_netmask;
+    char *arg_defgw_ipaddr;
+} IPMILan;
+
 #define MAX_NETFNS 64
 
 typedef struct IPMIRcvBufEntry {
@@ -215,6 +240,7 @@ struct IPMIBmcSim {
     IPMIFru fru;
     IPMISensor sensors[MAX_SENSORS];
     char *sdr_filename;
+    IPMILan lan;
 
     /* Odd netfns are for responses, so we only need the even ones. */
     const IPMINetfn *netfns[MAX_NETFNS / 2];
@@ -265,6 +291,36 @@ struct IPMIBmcSim {
 #define IPMI_BMC_WATCHDOG_ACTION_POWER_DOWN      2
 #define IPMI_BMC_WATCHDOG_ACTION_POWER_CYCLE     3
 
+#define IPMI_CHANNEL_IMPLEMENTATION_MIN    0x1
+#define IPMI_CHANNEL_IMPLEMENTATION_MAX    0xb
+#define IPMI_CHANNEL_IS_IMPLEMENTATION_SPECIFIC(c) \
+    (IPMI_CHANNEL_IMPLEMENTATION_MIN <= (c) && \
+     (c) <= IPMI_CHANNEL_IMPLEMENTATION_MAX)
+#define IPMI_CHANNEL_IS_LAN(ibs, c) \
+    ((ibs)->lan.channel == (c) && IPMI_CHANNEL_IS_IMPLEMENTATION_SPECIFIC(c))
+
+#define IPMI_BMC_LAN_CFG_CC_PARAM_NOT_SUPPORTED    0x80
+#define IPMI_BMC_LAN_CFG_CC_PARAM_READONLY         0x82
+
+#define IPMI_BMC_LAN_CFG_PARAM_SET_IN_PROGRESS        0x00
+#define IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_SUPPORT      0x01
+#define IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_ENABLES      0x02
+#define IPMI_BMC_LAN_CFG_PARAM_IP_ADDR                0x03
+#define IPMI_BMC_LAN_CFG_PARAM_IP_ADDR_SOURCE         0x04
+#define IPMI_BMC_LAN_CFG_PARAM_MAC_ADDR               0x05
+#define IPMI_BMC_LAN_CFG_PARAM_SUBNET_MASK            0x06
+#define IPMI_BMC_LAN_CFG_PARAM_IPV4_HDR_PARAMS        0x07
+#define IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_IP_ADDR     0x0c
+#define IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_MAC_ADDR    0x0d
+#define IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_ADDR         0x0e
+#define IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_MAC_ADDR     0x0f
+#define IPMI_BMC_LAN_CFG_PARAM_COMMUNITY_STRING       0x10
+#define IPMI_BMC_LAN_CFG_PARAM_NUM_DESTINATIONS       0x11
+
+#define IPMI_BMC_LAN_CFG_PARAMETER_REVISION    0x11
+
+#define IPMI_BMC_LAN_CFG_IS_VALID_IP_SOURCE(v)    (0x0 <= (v) && (v) <= 0x4)
+
 #define RSP_BUFFER_INITIALIZER { }
 
 static inline void rsp_buffer_pushmore(RspBuffer *rsp, uint8_t *bytes,
@@ -1231,6 +1287,25 @@ static void get_watchdog_timer(IPMIBmcSim *ibs,
     }
 }
 
+static void get_channel_access(IPMIBmcSim *ibs,
+                               uint8_t *cmd, unsigned int cmd_len,
+                               RspBuffer *rsp)
+{
+    uint8_t channel = cmd[2] & 0xf;
+
+    if (channel == IPMI_CHANNEL_IPMB || channel == IPMI_CHANNEL_SYSTEM ||
+        IPMI_CHANNEL_IS_LAN(ibs, channel)) {
+        /* alerting disabled */
+        /* per message authentication disabled */
+        /* user level authentication disabled */
+        /* channel always available */
+        rsp_buffer_push(rsp, 0x20 | 0x10 | 0x08 | 0x02);
+        rsp_buffer_push(rsp, 0x04);  /* privilege limit: ADMINISTRATOR */
+    } else {
+        rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD);
+    }
+}
+
 static void get_channel_info(IPMIBmcSim *ibs,
                              uint8_t *cmd, unsigned int cmd_len,
                              RspBuffer *rsp)
@@ -1240,29 +1315,29 @@ static void get_channel_info(IPMIBmcSim *ibs,
     IPMIFwInfo info = {};
     uint8_t ch = cmd[2] & 0x0f;
 
-    /* Only define channel 0h (IPMB) and Fh (system interface) */
-
     if (ch == 0x0e) { /* "This channel" */
         ch = IPMI_CHANNEL_SYSTEM;
     }
     rsp_buffer_push(rsp, ch);
 
-    if (ch != IPMI_CHANNEL_IPMB && ch != IPMI_CHANNEL_SYSTEM) {
-        /* Not a supported channel */
-        rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD);
-        return;
-    }
-
     if (k->get_fwinfo) {
         k->get_fwinfo(s, &info);
     }
 
+    /* Only define channel 0h (IPMB), LAN, and Fh (system interface) */
     if (ch == IPMI_CHANNEL_IPMB) {
         rsp_buffer_push(rsp, IPMI_CHANNEL_MEDIUM_IPMB);
         rsp_buffer_push(rsp, IPMI_CHANNEL_PROTOCOL_IPMB);
-    } else { /* IPMI_CHANNEL_SYSTEM */
+    } else if (IPMI_CHANNEL_IS_LAN(ibs, ch)) {
+        rsp_buffer_push(rsp, IPMI_CHANNEL_MEDIUM_802_3_LAN);
+        rsp_buffer_push(rsp, IPMI_CHANNEL_PROTOCOL_IPMB);
+    } else if (ch == IPMI_CHANNEL_SYSTEM) {
         rsp_buffer_push(rsp, IPMI_CHANNEL_MEDIUM_SYSTEM);
         rsp_buffer_push(rsp, info.ipmi_channel_protocol);
+    } else {
+        /* Not a supported channel */
+        rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD);
+        return;
     }
 
     rsp_buffer_push(rsp, 0x00); /* Session-less */
@@ -2045,6 +2120,223 @@ static void set_sensor_reading(IPMIBmcSim *ibs,
     }
 }
 
+static inline bool is_valid_netmask(const uint8_t *netmask)
+{
+    uint32_t mask = netmask[3];
+    uint32_t inverted;
+
+    mask |= (uint32_t) netmask[2] << 8;
+    mask |= (uint32_t) netmask[1] << 16;
+    mask |= (uint32_t) netmask[0] << 24;
+    inverted = ~mask;
+    return mask != 0 && (inverted & (inverted + 1)) == 0;
+}
+
+/*
+ * Request data (from cmd[2] on):
+ * bytes   meaning
+ *    1    [bits 3:0] channel number
+ *    2    parameter selector
+ * [3:N]   configuration parameter data (from cmd[4] on)
+ */
+static void set_lan_config(IPMIBmcSim *ibs,
+                           uint8_t *cmd, unsigned int cmd_len,
+                           RspBuffer *rsp)
+{
+    uint8_t channel = cmd[2] & 0xf;
+    uint8_t *param = cmd + 4;  /* pointer to configuration parameter data */
+    unsigned int param_len = cmd_len - 4;
+
+    if (!IPMI_CHANNEL_IS_LAN(ibs, channel)) {
+        rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD);
+        return;
+    }
+
+    switch (cmd[3]) {
+    case IPMI_BMC_LAN_CFG_PARAM_IP_ADDR:
+        if (param_len < NBYTES_IP) {
+            rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID);
+            return;
+        }
+        memcpy(ibs->lan.ipaddr, param, NBYTES_IP);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_IP_ADDR_SOURCE:
+        if (param_len < 1) {
+            rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID);
+            return;
+        }
+        if (!IPMI_BMC_LAN_CFG_IS_VALID_IP_SOURCE(*param)) {
+            rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD);
+            return;
+        }
+        ibs->lan.ipsrc = *param;
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_MAC_ADDR:
+        if (param_len < NBYTES_MAC) {
+            rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID);
+            return;
+        }
+        memcpy(ibs->lan.macaddr.a, param, NBYTES_MAC);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_SUBNET_MASK:
+        if (param_len < NBYTES_IP) {
+            rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID);
+            return;
+        }
+        if (!is_valid_netmask(param)) {
+            rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD);
+            return;
+        }
+        memcpy(ibs->lan.netmask, param, NBYTES_IP);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_IP_ADDR:
+        if (param_len < NBYTES_IP) {
+            rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID);
+            return;
+        }
+        memcpy(ibs->lan.defgw_ipaddr, param, NBYTES_IP);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_MAC_ADDR:
+        if (param_len < NBYTES_MAC) {
+            rsp_buffer_set_error(rsp, IPMI_CC_REQUEST_DATA_LENGTH_INVALID);
+            return;
+        }
+        memcpy(ibs->lan.defgw_macaddr.a, param, NBYTES_MAC);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_SET_IN_PROGRESS:
+    case IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_SUPPORT:
+    case IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_ENABLES:
+    case IPMI_BMC_LAN_CFG_PARAM_IPV4_HDR_PARAMS:
+    case IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_ADDR:
+    case IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_MAC_ADDR:
+    case IPMI_BMC_LAN_CFG_PARAM_COMMUNITY_STRING:
+    case IPMI_BMC_LAN_CFG_PARAM_NUM_DESTINATIONS:
+        rsp_buffer_set_error(rsp, IPMI_BMC_LAN_CFG_CC_PARAM_READONLY);
+        return;
+
+    default:
+        rsp_buffer_set_error(rsp, IPMI_BMC_LAN_CFG_CC_PARAM_NOT_SUPPORTED);
+        return;
+    }
+}
+
+/*
+ * Request data (from cmd[2] to cmd[5] inclusive):
+ * bytes   meaning
+ *    1    [bit 7] revision only flag, [bits 3:0] channel number
+ *    2    parameter selector
+ *    3    set selector
+ *    4    block selector
+ */
+static void get_lan_config(IPMIBmcSim *ibs,
+                           uint8_t *cmd, unsigned int cmd_len,
+                           RspBuffer *rsp)
+{
+    uint8_t channel = cmd[2] & 0xf;
+
+    rsp_buffer_push(rsp, IPMI_BMC_LAN_CFG_PARAMETER_REVISION);
+    if (cmd[2] & 0x80) {
+        /* The requester only requests parameter revision, not the parameter */
+        return;
+    }
+    if (!IPMI_CHANNEL_IS_LAN(ibs, channel)) {
+        rsp_buffer_set_error(rsp, IPMI_CC_INVALID_DATA_FIELD);
+        return;
+    }
+
+    switch (cmd[3]) {
+    case IPMI_BMC_LAN_CFG_PARAM_SET_IN_PROGRESS:
+        rsp_buffer_push(rsp, 0x0);  /* set complete */
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_SUPPORT:
+        rsp_buffer_push(rsp, 0x01); /* Authentication type "none" supported */
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_AUTH_TYPE_ENABLES:
+        /* Only authentication type "none" enabled */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "Callback" */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "User" */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "Operator" */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "Administrator" */
+        rsp_buffer_push(rsp, 0x01); /* for privilege level "OEM" */
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_IP_ADDR:
+        rsp_buffer_pushmore(rsp, ibs->lan.ipaddr, NBYTES_IP);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_IP_ADDR_SOURCE:
+        rsp_buffer_push(rsp, ibs->lan.ipsrc);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_MAC_ADDR:
+        rsp_buffer_pushmore(rsp, ibs->lan.macaddr.a, NBYTES_MAC);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_SUBNET_MASK:
+        rsp_buffer_pushmore(rsp, ibs->lan.netmask, NBYTES_IP);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_IPV4_HDR_PARAMS:
+        /* TTL 0x40 */
+        rsp_buffer_push(rsp, 0x40);
+        /* don't fragment */
+        rsp_buffer_push(rsp, 0x40);
+        /* precedence 0x0, minimize delay */
+        rsp_buffer_push(rsp, 0x10);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_IP_ADDR:
+        rsp_buffer_pushmore(rsp, ibs->lan.defgw_ipaddr, NBYTES_IP);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_DEFAULT_GW_MAC_ADDR:
+        rsp_buffer_pushmore(rsp, ibs->lan.defgw_macaddr.a, NBYTES_MAC);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_ADDR:
+        /* 0.0.0.0 */
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_BACKUP_GW_MAC_ADDR:
+        /* 00:00:00:00:00:00 */
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        rsp_buffer_push(rsp, 0x00);
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_COMMUNITY_STRING:
+        {
+            static uint8_t community_str[18] = "public";
+
+            rsp_buffer_pushmore(rsp, community_str, sizeof(community_str));
+        }
+        break;
+
+    case IPMI_BMC_LAN_CFG_PARAM_NUM_DESTINATIONS:
+        rsp_buffer_push(rsp, 0x00); /* LAN Alerting not supported */
+        break;
+
+    default:
+        rsp_buffer_set_error(rsp, IPMI_BMC_LAN_CFG_CC_PARAM_NOT_SUPPORTED);
+        return;
+    };
+}
+
 static const IPMICmdHandler chassis_cmds[] = {
     [IPMI_CMD_GET_CHASSIS_CAPABILITIES] = { chassis_capabilities },
     [IPMI_CMD_GET_CHASSIS_STATUS] = { chassis_status },
@@ -2089,6 +2381,7 @@ static const IPMICmdHandler app_cmds[] = {
     [IPMI_CMD_RESET_WATCHDOG_TIMER] = { reset_watchdog_timer },
     [IPMI_CMD_SET_WATCHDOG_TIMER] = { set_watchdog_timer, 8 },
     [IPMI_CMD_GET_WATCHDOG_TIMER] = { get_watchdog_timer },
+    [IPMI_CMD_GET_CHANNEL_ACCESS] = { get_channel_access, 4 },
     [IPMI_CMD_GET_CHANNEL_INFO] = { get_channel_info, 3 },
 };
 static const IPMINetfn app_netfn = {
@@ -2119,12 +2412,23 @@ static const IPMINetfn storage_netfn = {
     .cmd_handlers = storage_cmds
 };
 
+static const IPMICmdHandler transport_cmds[] = {
+    [IPMI_CMD_SET_LAN_CONFIG] = { set_lan_config, 5 },
+    [IPMI_CMD_GET_LAN_CONFIG] = { get_lan_config, 6 },
+};
+static const IPMINetfn transport_netfn = {
+    .cmd_nums = ARRAY_SIZE(transport_cmds),
+    .cmd_handlers = transport_cmds
+};
+
+
 static void register_cmds(IPMIBmcSim *s)
 {
     ipmi_sim_register_netfn(s, IPMI_NETFN_CHASSIS, &chassis_netfn);
     ipmi_sim_register_netfn(s, IPMI_NETFN_SENSOR_EVENT, &sensor_event_netfn);
     ipmi_sim_register_netfn(s, IPMI_NETFN_APP, &app_netfn);
     ipmi_sim_register_netfn(s, IPMI_NETFN_STORAGE, &storage_netfn);
+    ipmi_sim_register_netfn(s, IPMI_NETFN_TRANSPORT, &transport_netfn);
 }
 
 static uint8_t init_sdrs[] = {
@@ -2176,7 +2480,7 @@ static void ipmi_sdr_init(IPMIBmcSim *ibs)
 
 static const VMStateDescription vmstate_ipmi_sim = {
     .name = TYPE_IPMI_BMC_SIMULATOR,
-    .version_id = 1,
+    .version_id = 2,
     .minimum_version_id = 1,
     .fields = (const VMStateField[]) {
         VMSTATE_UINT8(bmc_global_enables, IPMIBmcSim),
@@ -2198,6 +2502,13 @@ static const VMStateDescription vmstate_ipmi_sim = {
         VMSTATE_UINT16(sensors[IPMI_WATCHDOG_SENSOR].deassert_states,
                        IPMIBmcSim),
         VMSTATE_UINT16(sensors[IPMI_WATCHDOG_SENSOR].assert_enable, IPMIBmcSim),
+        VMSTATE_UINT8_V(lan.channel, IPMIBmcSim, 2),
+        VMSTATE_UINT8_ARRAY_V(lan.ipaddr, IPMIBmcSim, NBYTES_IP, 2),
+        VMSTATE_UINT8_V(lan.ipsrc, IPMIBmcSim, 2),
+        VMSTATE_UINT8_ARRAY_V(lan.macaddr.a, IPMIBmcSim, NBYTES_MAC, 2),
+        VMSTATE_UINT8_ARRAY_V(lan.netmask, IPMIBmcSim, NBYTES_IP, 2),
+        VMSTATE_UINT8_ARRAY_V(lan.defgw_ipaddr, IPMIBmcSim, NBYTES_IP, 2),
+        VMSTATE_UINT8_ARRAY_V(lan.defgw_macaddr.a, IPMIBmcSim, NBYTES_MAC, 2),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -2232,6 +2543,38 @@ out:
     fru->nentries = size / fru->areasize;
 }
 
+static void ipmi_lan_init(IPMILan *lan, Error **errp)
+{
+    struct in_addr ip;
+
+    if (lan->arg_ipaddr) {
+        if (inet_pton(AF_INET, lan->arg_ipaddr, &ip) != 1) {
+            error_setg(errp, "invalid ip address '%s'", lan->arg_ipaddr);
+            return;
+        }
+        memcpy(lan->ipaddr, &ip.s_addr, NBYTES_IP);
+    }
+    if (!IPMI_BMC_LAN_CFG_IS_VALID_IP_SOURCE(lan->ipsrc)) {
+        error_setg(errp, "invalid ip source %d", lan->ipsrc);
+        return;
+    }
+    if (lan->arg_netmask) {
+        if (inet_pton(AF_INET, lan->arg_netmask, &ip) != 1 ||
+            !is_valid_netmask((const uint8_t *) &ip.s_addr)) {
+            error_setg(errp, "invalid subnet mask '%s'", lan->arg_netmask);
+            return;
+        }
+        memcpy(lan->netmask, &ip.s_addr, NBYTES_IP);
+    }
+    if (lan->arg_defgw_ipaddr) {
+        if (inet_pton(AF_INET, lan->arg_defgw_ipaddr, &ip) != 1) {
+            error_setg(errp, "invalid ip address '%s'", lan->arg_defgw_ipaddr);
+            return;
+        }
+        memcpy(lan->defgw_ipaddr, &ip.s_addr, NBYTES_IP);
+    }
+}
+
 static void ipmi_sim_realize(DeviceState *dev, Error **errp)
 {
     IPMIBmc *b = IPMI_BMC(dev);
@@ -2259,6 +2602,9 @@ static void ipmi_sim_realize(DeviceState *dev, Error **errp)
     ibs->acpi_power_state[1] = 0;
 
     ipmi_init_sensors_from_sdrs(ibs);
+
+    ipmi_lan_init(&ibs->lan, errp);
+
     register_cmds(ibs);
 
     ibs->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ipmi_timeout, ibs);
@@ -2276,6 +2622,13 @@ static const Property ipmi_sim_properties[] = {
     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_UINT8("lan_channel", IPMIBmcSim, lan.channel, 0),
+    DEFINE_PROP_STRING("lan_ipaddr", IPMIBmcSim, lan.arg_ipaddr),
+    DEFINE_PROP_UINT8("lan_ipsrc", IPMIBmcSim, lan.ipsrc, 0),
+    DEFINE_PROP_MACADDR("lan_macaddr", IPMIBmcSim, lan.macaddr),
+    DEFINE_PROP_STRING("lan_netmask", IPMIBmcSim, lan.arg_netmask),
+    DEFINE_PROP_STRING("lan_defgw_ipaddr", IPMIBmcSim, lan.arg_defgw_ipaddr),
+    DEFINE_PROP_MACADDR("lan_defgw_macaddr", IPMIBmcSim, lan.defgw_macaddr),
 };
 
 static void ipmi_sim_class_init(ObjectClass *oc, const void *data)
diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
index cd581aa134..3435d84178 100644
--- a/include/hw/ipmi/ipmi.h
+++ b/include/hw/ipmi/ipmi.h
@@ -45,6 +45,7 @@ enum ipmi_op {
 #define IPMI_CHANNEL_IPMB                0x00
 #define IPMI_CHANNEL_SYSTEM              0x0f
 #define IPMI_CHANNEL_MEDIUM_IPMB         0x01
+#define IPMI_CHANNEL_MEDIUM_802_3_LAN    0x04
 #define IPMI_CHANNEL_MEDIUM_SYSTEM       0x0c
 #define IPMI_CHANNEL_PROTOCOL_IPMB       0x01
 #define IPMI_CHANNEL_PROTOCOL_KCS        0x05
diff --git a/tests/qtest/ipmi-kcs-test.c b/tests/qtest/ipmi-kcs-test.c
index 3186c6ad64..c1f28dff69 100644
--- a/tests/qtest/ipmi-kcs-test.c
+++ b/tests/qtest/ipmi-kcs-test.c
@@ -262,6 +262,125 @@ static void test_enable_irq(void)
     kcs_ints_enabled = 1;
 }
 
+
+static uint8_t get_channel_access_cmd[] = { 0x18, 0x41, 0x01, 0x40 };
+static uint8_t get_channel_access_rsp[] = { 0x1c, 0x41, 0x00, 0x3a, 0x04 };
+
+/*
+ * Get channel access
+ */
+static void test_kcs_channel_access(void)
+{
+    uint8_t rsp[20];
+    unsigned int rsplen = sizeof(rsp);
+
+    kcs_cmd(get_channel_access_cmd, sizeof(get_channel_access_cmd),
+            rsp, &rsplen);
+    g_assert(rsplen == sizeof(get_channel_access_rsp));
+    g_assert(memcmp(get_channel_access_rsp, rsp, rsplen) == 0);
+}
+
+
+static uint8_t get_channel_info_cmd[] = { 0x18, 0x42, 0x01 };
+static uint8_t get_channel_info_rsp[] = { 0x1c, 0x42, 0x00, 0x01, 0x04, 0x01,
+                                          0x00, 0xf2, 0x1b, 0x00, 0x00, 0x00 };
+
+/*
+ * Get channel info
+ */
+static void test_kcs_channel_info(void)
+{
+    uint8_t rsp[20];
+    unsigned int rsplen = sizeof(rsp);
+
+    kcs_cmd(get_channel_info_cmd, sizeof(get_channel_info_cmd), rsp, &rsplen);
+    g_assert(rsplen == sizeof(get_channel_info_rsp));
+    g_assert(memcmp(get_channel_info_rsp, rsp, rsplen) == 0);
+}
+
+
+/* set/get ip address: 192.0.2.2 */
+static uint8_t set_lan_ipaddr_cmd[] = { 0x30, 0x01, 0x01, 0x03,
+                                        0xc0, 0x00, 0x02, 0x02 };
+static uint8_t set_lan_ipaddr_rsp[] = { 0x34, 0x01, 0x00 };
+static uint8_t get_lan_ipaddr_cmd[] = { 0x30, 0x02, 0x01, 0x03, 0x00, 0x00 };
+static uint8_t get_lan_ipaddr_rsp[] = { 0x34, 0x02, 0x00, 0x11,
+                                        0xc0, 0x00, 0x02, 0x02 };
+/* set ip address source: static */
+static uint8_t set_lan_ipsrc_cmd[] = { 0x30, 0x01, 0x01, 0x04, 0x01 };
+static uint8_t set_lan_ipsrc_rsp[] = { 0x34, 0x01, 0x00 };
+
+/* set/get subnet mask: 255.255.255.0 */
+static uint8_t set_lan_netmask_cmd[] = { 0x30, 0x01, 0x01, 0x06,
+                                         0xff, 0xff, 0xff, 0x00 };
+static uint8_t set_lan_netmask_rsp[] = { 0x34, 0x01, 0x00 };
+static uint8_t get_lan_netmask_cmd[] = { 0x30, 0x02, 0x01, 0x06, 0x00, 0x00 };
+static uint8_t get_lan_netmask_rsp[] = { 0x34, 0x02, 0x00, 0x11,
+                                         0xff, 0xff, 0xff, 0x00 };
+
+/* set/get default gateway ip address: 192.0.2.1 */
+static uint8_t set_lan_defgw_ipaddr_cmd[] = { 0x30, 0x01, 0x01, 0x0c,
+                                              0xc0, 0x00, 0x02, 0x01 };
+static uint8_t set_lan_defgw_ipaddr_rsp[] = { 0x34, 0x01, 0x00 };
+static uint8_t get_lan_defgw_ipaddr_cmd[] = { 0x30, 0x02, 0x01, 0x0c,
+                                              0x00, 0x00 };
+static uint8_t get_lan_defgw_ipaddr_rsp[] = { 0x34, 0x02, 0x00, 0x11,
+                                              0xc0, 0x00, 0x02, 0x01 };
+
+/*
+ * Set and get LAN configurations
+ */
+static void test_kcs_lan(void)
+{
+    uint8_t rsp[20];
+    unsigned int rsplen = 0;
+
+    /* set ip address */
+    rsplen = sizeof(rsp);
+    kcs_cmd(set_lan_ipaddr_cmd, sizeof(set_lan_ipaddr_cmd), rsp, &rsplen);
+    g_assert(rsplen == sizeof(set_lan_ipaddr_rsp));
+    g_assert(memcmp(set_lan_ipaddr_rsp, rsp, rsplen) == 0);
+
+    /* get ip address */
+    rsplen = sizeof(rsp);
+    kcs_cmd(get_lan_ipaddr_cmd, sizeof(get_lan_ipaddr_cmd), rsp, &rsplen);
+    g_assert(rsplen == sizeof(get_lan_ipaddr_rsp));
+    g_assert(memcmp(get_lan_ipaddr_rsp, rsp, rsplen) == 0);
+
+    /* set ip address source */
+    rsplen = sizeof(rsp);
+    kcs_cmd(set_lan_ipsrc_cmd, sizeof(set_lan_ipsrc_cmd), rsp, &rsplen);
+    g_assert(rsplen == sizeof(set_lan_ipsrc_rsp));
+    g_assert(memcmp(set_lan_ipsrc_rsp, rsp, rsplen) == 0);
+
+    /* set subnet mask */
+    rsplen = sizeof(rsp);
+    kcs_cmd(set_lan_netmask_cmd, sizeof(set_lan_netmask_cmd), rsp, &rsplen);
+    g_assert(rsplen == sizeof(set_lan_netmask_rsp));
+    g_assert(memcmp(set_lan_netmask_rsp, rsp, rsplen) == 0);
+
+    /* get subnet mask */
+    rsplen = sizeof(rsp);
+    kcs_cmd(get_lan_netmask_cmd, sizeof(get_lan_netmask_cmd), rsp, &rsplen);
+    g_assert(rsplen == sizeof(get_lan_netmask_rsp));
+    g_assert(memcmp(get_lan_netmask_rsp, rsp, rsplen) == 0);
+
+    /* set default gateway ip address */
+    rsplen = sizeof(rsp);
+    kcs_cmd(set_lan_defgw_ipaddr_cmd, sizeof(set_lan_defgw_ipaddr_cmd),
+            rsp, &rsplen);
+    g_assert(rsplen == sizeof(set_lan_defgw_ipaddr_rsp));
+    g_assert(memcmp(set_lan_defgw_ipaddr_rsp, rsp, rsplen) == 0);
+
+    /* get default gateway ip address */
+    rsplen = sizeof(rsp);
+    kcs_cmd(get_lan_defgw_ipaddr_cmd, sizeof(get_lan_defgw_ipaddr_cmd),
+            rsp, &rsplen);
+    g_assert(rsplen == sizeof(get_lan_defgw_ipaddr_rsp));
+    g_assert(memcmp(get_lan_defgw_ipaddr_rsp, rsp, rsplen) == 0);
+}
+
+
 int main(int argc, char **argv)
 {
     char *cmdline;
@@ -270,7 +389,7 @@ int main(int argc, char **argv)
     /* Run the tests */
     g_test_init(&argc, &argv, NULL);
 
-    cmdline = g_strdup_printf("-device ipmi-bmc-sim,id=bmc0"
+    cmdline = g_strdup_printf("-device ipmi-bmc-sim,id=bmc0,lan_channel=1"
                               " -device isa-ipmi-kcs,bmc=bmc0");
     qtest_start(cmdline);
     g_free(cmdline);
@@ -280,6 +399,9 @@ int main(int argc, char **argv)
     qtest_add_func("/ipmi/local/kcs_enable_irq", test_enable_irq);
     qtest_add_func("/ipmi/local/kcs_base_irq", test_kcs_base);
     qtest_add_func("/ipmi/local/kcs_abort_irq", test_kcs_abort);
+    qtest_add_func("/ipmi/local/kcs_channel_access", test_kcs_channel_access);
+    qtest_add_func("/ipmi/local/kcs_channel_info", test_kcs_channel_info);
+    qtest_add_func("/ipmi/local/kcs_lan", test_kcs_lan);
     ret = g_test_run();
     qtest_quit(global_qtest);
 
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
  2025-10-14 12:19     ` Yunpeng Yang
@ 2025-10-14 23:17       ` Corey Minyard
  2025-10-20  8:34         ` Yunpeng Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Corey Minyard @ 2025-10-14 23:17 UTC (permalink / raw)
  To: Yunpeng Yang
  Cc: minyard@acm.org, qemu-devel@nongnu.org, Mark Cave-Ayland,
	Jonathan Davies

On Tue, Oct 14, 2025 at 12:19:53PM +0000, Yunpeng Yang wrote:
> Hello Corey,
> 
> I hope you are all well.
> 
> I've finally come up with a patch for implementing the fake LAN configurations for the device ipmi-bmc-sim. My apologies for the long long delay. And thank you for your patience.
> 
> Please find attached the patch file. The patch is base on commit: bd6aa0d1e5 ("Merge tag 'staging-pull-request' of https://gitlab.com/peterx/qemu into staging"). Could you please review the patch and let me know your opinions?

The patch is mostly ok, the general principles are sound.

A few things:

Can you put the patch inline in the email instead of attaching it?  In
general, it is hard to deal with attachments when commenting on things.
Use git-send-email or git-format-patch or something like that.  You can
look in the Linux kernel docs for how to do this.

I could not find a check on the lan.channel value to make sure it is in
range and doesn't conflict with an existing channel.  If a check is not
there it needs to be done.

I would like to keep the behavior as close as possible to the current
behavior.  If a channel is not defined, get_lan_config() and
set_lan_config() should return the same value as if the command was not
defined.  I think get_channel_access() is ok as it is.

You need to add documentation in qemu-options.hx.

Can you copy Cornelia Huck <cornelia.huck@de.ibm.com> on the next
version?  The IBM people are the biggest users of the ipmi code,
and I don't want this to catch them off guard.

If the patch gets too big, feel free to split it into multiple parts.

Thanks,

-corey

> 
> Looking forward to hearing back from you.
> 
> Kind regards,
> Yunpeng Yang
> 
> 
> 
> ________________________________
> From: Corey Minyard <corey@minyard.net>
> Sent: Sunday, August 03, 2025 14:22
> To: Yunpeng Yang <yunpeng.yang@nutanix.com>
> Cc: minyard@acm.org <minyard@acm.org>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>; Mark Cave-Ayland <mark.caveayland@nutanix.com>; Jonathan Davies <jond@nutanix.com>
> Subject: Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
> 
> On Sun, Aug 3, 2025 at 6: 16 AM Yunpeng Yang <yunpeng. yang@ nutanix. com> wrote: Hello Corey Minyard, I hope you are all well. Could I ask for your opinion on whether it is worthing implementing a fake LAN config for device ipmi-bmc-sim ?
> ZjQcmQRYFpfptBannerStart
> CAUTION: External Email
> 
> ZjQcmQRYFpfptBannerEnd
> On Sun, Aug 3, 2025 at 6:16 AM Yunpeng Yang <yunpeng.yang@nutanix.com<mailto:yunpeng.yang@nutanix.com>> wrote:
> Hello Corey Minyard,
> 
> I hope you are all well.
> 
> Could I ask for your opinion on whether it is worthing implementing a fake LAN config for device ipmi-bmc-sim ? (Details are in my last email, which is also included below).
> 
> During my work over last month, I found that QEMU already has ipmi-bmc-extern which supports comprehensive BMC simulation, including LAN config faking. But ipmi-bmc-sim is more light-weight and easier to set up. So I think it still has some value in implementing LAN config for ipmi-bmc-sim . Could you please share your views?
> 
> 
> Well, there is no LAN interface, so I didn't see any need to add that.  The values would not be permanent.  But it would be harmless to add, so I'd be ok with a patch to do this.
> 
> The external interface with ipmisim from the OpenIPMI library provides a pretty comprehensive solution.
> 
> -corey
> 
> Best regards,
> Yunpeng Yang
> 
> 
> ________________________________
> From: Yunpeng Yang <yunpeng.yang@nutanix.com<mailto:yunpeng.yang@nutanix.com>>
> Sent: Friday, June 27, 2025 18:13
> To: minyard@acm.org<mailto:minyard@acm.org> <minyard@acm.org<mailto:minyard@acm.org>>
> Cc: qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org> <qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org>>; Mark Cave-Ayland <mark.caveayland@nutanix.com<mailto:mark.caveayland@nutanix.com>>; Jonathan Davies <jond@nutanix.com<mailto:jond@nutanix.com>>
> Subject: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
> 
> Hello Corey Minyard,
> 
> I hope this email finds you well.
> 
> I'm currently adding LAN-configs-retrieval support to the QEMU ipmi-bmc-sim device. And I hope to merge the modifications upstream after it's finished. Could you please check the attached patch file of the draft code and share your opinions and advice?
> 
> In my work, we need to run tools like "ipmitool lan print" on a VM for testing purposes. However, QEMU internal BMC simulator device (`ipmi-bmc-sim`) does not support retrieving LAN configs from it. I have to implement two IPMI commands so that the device can now work with ipmitool. The LAN config values are faked, but for testing purposes this is not a problem. I believe other people may also have the same need, so it's worth getting merged upstream.
> 
> The fake BMC LAN config values are currently hard coded into the code. My plan is to add a parameter to the device, which is a file containing user designated values. The device then reads the file and returns those values as LAN configs. This is similar to sdrfile for sensor data and frudatafile for FRU data.
> 
> Looking forward to hearing your thoughts.
> Have a nice weekend.
> 
> Kind regards,
> Yunpeng Yang




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
  2025-10-14 23:17       ` Corey Minyard
@ 2025-10-20  8:34         ` Yunpeng Yang
  0 siblings, 0 replies; 7+ messages in thread
From: Yunpeng Yang @ 2025-10-20  8:34 UTC (permalink / raw)
  To: corey@minyard.net
  Cc: minyard@acm.org, qemu-devel@nongnu.org, Mark Cave-Ayland,
	Jonathan Davies

[-- Attachment #1: Type: text/plain, Size: 6325 bytes --]

Hi Corey,

Thank you for reviewing the patch!
I'll revise it and put it inline and send you a new patch later.

Kind regards,
Yunpeng Yang


________________________________
From: Corey Minyard <corey@minyard.net>
Sent: Wednesday, October 15, 2025 00:17
To: Yunpeng Yang <yunpeng.yang@nutanix.com>
Cc: minyard@acm.org <minyard@acm.org>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>; Mark Cave-Ayland <mark.caveayland@nutanix.com>; Jonathan Davies <jond@nutanix.com>
Subject: Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device

!-------------------------------------------------------------------|
  CAUTION: External Email

|-------------------------------------------------------------------!

On Tue, Oct 14, 2025 at 12:19:53PM +0000, Yunpeng Yang wrote:
> Hello Corey,
>
> I hope you are all well.
>
> I've finally come up with a patch for implementing the fake LAN configurations for the device ipmi-bmc-sim. My apologies for the long long delay. And thank you for your patience.
>
> Please find attached the patch file. The patch is base on commit: bd6aa0d1e5 ("Merge tag 'staging-pull-request' of https://urldefense.proofpoint.com/v2/url?u=https-3A__gitlab.com_peterx_qemu&d=DwIDaQ&c=s883GpUCOChKOHiocYtGcg&r=gyJEZb_gH0rRUcKZUkVe15Lqy_BoDVLs3C-LhiDdmek&m=rfmLapMDI4Ee_0kJdoHlr3SDVhA8ZRzQ8uGSoMPqV7u-WryqTxU7x0I2YHUjPqCF&s=qrpat3zQSFjeayoVw4uZAnIyhoVgtck2A1C-AG9CJO0&e=  into staging"). Could you please review the patch and let me know your opinions?

The patch is mostly ok, the general principles are sound.

A few things:

Can you put the patch inline in the email instead of attaching it?  In
general, it is hard to deal with attachments when commenting on things.
Use git-send-email or git-format-patch or something like that.  You can
look in the Linux kernel docs for how to do this.

I could not find a check on the lan.channel value to make sure it is in
range and doesn't conflict with an existing channel.  If a check is not
there it needs to be done.

I would like to keep the behavior as close as possible to the current
behavior.  If a channel is not defined, get_lan_config() and
set_lan_config() should return the same value as if the command was not
defined.  I think get_channel_access() is ok as it is.

You need to add documentation in qemu-options.hx.

Can you copy Cornelia Huck <cornelia.huck@de.ibm.com> on the next
version?  The IBM people are the biggest users of the ipmi code,
and I don't want this to catch them off guard.

If the patch gets too big, feel free to split it into multiple parts.

Thanks,

-corey

>
> Looking forward to hearing back from you.
>
> Kind regards,
> Yunpeng Yang
>
>
>
> ________________________________
> From: Corey Minyard <corey@minyard.net>
> Sent: Sunday, August 03, 2025 14:22
> To: Yunpeng Yang <yunpeng.yang@nutanix.com>
> Cc: minyard@acm.org <minyard@acm.org>; qemu-devel@nongnu.org <qemu-devel@nongnu.org>; Mark Cave-Ayland <mark.caveayland@nutanix.com>; Jonathan Davies <jond@nutanix.com>
> Subject: Re: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
>
> On Sun, Aug 3, 2025 at 6: 16 AM Yunpeng Yang <yunpeng. yang@ nutanix. com> wrote: Hello Corey Minyard, I hope you are all well. Could I ask for your opinion on whether it is worthing implementing a fake LAN config for device ipmi-bmc-sim ?
> ZjQcmQRYFpfptBannerStart
> CAUTION: External Email
>
> ZjQcmQRYFpfptBannerEnd
> On Sun, Aug 3, 2025 at 6:16 AM Yunpeng Yang <yunpeng.yang@nutanix.com<mailto:yunpeng.yang@nutanix.com>> wrote:
> Hello Corey Minyard,
>
> I hope you are all well.
>
> Could I ask for your opinion on whether it is worthing implementing a fake LAN config for device ipmi-bmc-sim ? (Details are in my last email, which is also included below).
>
> During my work over last month, I found that QEMU already has ipmi-bmc-extern which supports comprehensive BMC simulation, including LAN config faking. But ipmi-bmc-sim is more light-weight and easier to set up. So I think it still has some value in implementing LAN config for ipmi-bmc-sim . Could you please share your views?
>
>
> Well, there is no LAN interface, so I didn't see any need to add that.  The values would not be permanent.  But it would be harmless to add, so I'd be ok with a patch to do this.
>
> The external interface with ipmisim from the OpenIPMI library provides a pretty comprehensive solution.
>
> -corey
>
> Best regards,
> Yunpeng Yang
>
>
> ________________________________
> From: Yunpeng Yang <yunpeng.yang@nutanix.com<mailto:yunpeng.yang@nutanix.com>>
> Sent: Friday, June 27, 2025 18:13
> To: minyard@acm.org<mailto:minyard@acm.org> <minyard@acm.org<mailto:minyard@acm.org>>
> Cc: qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org> <qemu-devel@nongnu.org<mailto:qemu-devel@nongnu.org>>; Mark Cave-Ayland <mark.caveayland@nutanix.com<mailto:mark.caveayland@nutanix.com>>; Jonathan Davies <jond@nutanix.com<mailto:jond@nutanix.com>>
> Subject: Add support for retrieving fake LAN config from `ipmi-bmc-sim` device
>
> Hello Corey Minyard,
>
> I hope this email finds you well.
>
> I'm currently adding LAN-configs-retrieval support to the QEMU ipmi-bmc-sim device. And I hope to merge the modifications upstream after it's finished. Could you please check the attached patch file of the draft code and share your opinions and advice?
>
> In my work, we need to run tools like "ipmitool lan print" on a VM for testing purposes. However, QEMU internal BMC simulator device (`ipmi-bmc-sim`) does not support retrieving LAN configs from it. I have to implement two IPMI commands so that the device can now work with ipmitool. The LAN config values are faked, but for testing purposes this is not a problem. I believe other people may also have the same need, so it's worth getting merged upstream.
>
> The fake BMC LAN config values are currently hard coded into the code. My plan is to add a parameter to the device, which is a file containing user designated values. The device then reads the file and returns those values as LAN configs. This is similar to sdrfile for sensor data and frudatafile for FRU data.
>
> Looking forward to hearing your thoughts.
> Have a nice weekend.
>
> Kind regards,
> Yunpeng Yang



[-- Attachment #2: Type: text/html, Size: 9721 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-20  8:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-27 17:13 Add support for retrieving fake LAN config from `ipmi-bmc-sim` device Yunpeng Yang
2025-08-03 11:15 ` Yunpeng Yang
2025-08-03 13:22   ` Corey Minyard
2025-08-04 12:08     ` Yunpeng Yang
2025-10-14 12:19     ` Yunpeng Yang
2025-10-14 23:17       ` Corey Minyard
2025-10-20  8:34         ` Yunpeng Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).