ID:322 - let 'ekanalyzer frushow' run without a working IPMI target

Commit changes a dummy interface in a way that it acts as a dummy interface when
no IPMI_DUMMY_SOCK env variable is set. Therefore, it's possible to run
'ekanalyzer frushow' without having BMC. Still, you need to specify this IPMI
interface.
If IPMI_DUMMY_SOCK is set, then dummy interface will work as it was working
before.
This commit is contained in:
Zdenek Styblik 2016-04-10 19:40:11 +02:00
parent f70a19cf63
commit 3123ce01b5
2 changed files with 16 additions and 3 deletions

View File

@ -31,6 +31,7 @@
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/un.h> #include <sys/un.h>
@ -175,6 +176,14 @@ ipmi_dummyipmi_open(struct ipmi_intf *intf)
struct sockaddr_un address; struct sockaddr_un address;
int len; int len;
int rc; int rc;
char *dummy_sock_path;
dummy_sock_path = getenv("IPMI_DUMMY_SOCK");
if (dummy_sock_path == NULL) {
lprintf(LOG_DEBUG, "No IPMI_DUMMY_SOCK set. Dummy mode ON.");
intf->opened = 1;
return intf->fd;
}
if (intf->opened == 1) { if (intf->opened == 1) {
return intf->fd; return intf->fd;
@ -185,7 +194,7 @@ ipmi_dummyipmi_open(struct ipmi_intf *intf)
return (-1); return (-1);
} }
address.sun_family = AF_UNIX; address.sun_family = AF_UNIX;
strcpy(address.sun_path, DUMMY_SOCKET_PATH); strcpy(address.sun_path, dummy_sock_path);
len = sizeof(address); len = sizeof(address);
rc = connect(intf->fd, (struct sockaddr *)&address, len); rc = connect(intf->fd, (struct sockaddr *)&address, len);
if (rc != 0) { if (rc != 0) {
@ -209,6 +218,12 @@ ipmi_dummyipmi_send_cmd(struct ipmi_intf *intf, struct ipmi_rq *req)
static struct ipmi_rs rsp; static struct ipmi_rs rsp;
struct dummy_rq req_dummy; struct dummy_rq req_dummy;
struct dummy_rs rsp_dummy; struct dummy_rs rsp_dummy;
char *dummy_sock_path;
dummy_sock_path = getenv("IPMI_DUMMY_SOCK");
if (dummy_sock_path == NULL) {
lprintf(LOG_DEBUG, "No IPMI_DUMMY_SOCK set. Dummy mode ON.");
return NULL;
}
if (intf == NULL || intf->fd < 0 || intf->opened != 1) { if (intf == NULL || intf->fd < 0 || intf->opened != 1) {
lprintf(LOG_ERR, "dummy failed on intf check."); lprintf(LOG_ERR, "dummy failed on intf check.");
return NULL; return NULL;

View File

@ -1,8 +1,6 @@
#ifndef IPMI_DUMMYIPMI_H #ifndef IPMI_DUMMYIPMI_H
# define IPMI_DUMMYIPMI_H # define IPMI_DUMMYIPMI_H
# define DUMMY_SOCKET_PATH "/tmp/.ipmi_dummy"
struct dummy_rq { struct dummy_rq {
struct { struct {
uint8_t netfn; uint8_t netfn;