2009-11-05 16:18:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright IBM Corp. 2009
|
|
|
|
*
|
|
|
|
* phyp_driver.c: ssh layer to access Power Hypervisors
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Eduardo Otubo <otubo at linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "conf/capabilities.h"
|
|
|
|
#include "conf/domain_conf.h"
|
2009-07-24 14:17:06 +00:00
|
|
|
#include <config.h>
|
2009-09-04 10:08:47 +00:00
|
|
|
#include <libssh2.h>
|
2009-07-24 14:17:06 +00:00
|
|
|
|
|
|
|
#define LPAR_EXEC_ERR -1
|
|
|
|
#define SSH_CONN_ERR -2 /* error while trying to connect to remote host */
|
|
|
|
#define SSH_CMD_ERR -3 /* error while trying to execute the remote cmd */
|
|
|
|
|
|
|
|
typedef struct _ConnectionData ConnectionData;
|
|
|
|
typedef ConnectionData *ConnectionDataPtr;
|
|
|
|
struct _ConnectionData {
|
2009-09-04 10:08:47 +00:00
|
|
|
LIBSSH2_SESSION *session;
|
2009-07-24 14:17:06 +00:00
|
|
|
virConnectAuthPtr auth;
|
2009-09-04 10:08:47 +00:00
|
|
|
int sock;
|
2009-07-24 14:17:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This is the lpar (domain) struct that relates
|
|
|
|
* the ID with UUID generated by the API
|
|
|
|
* */
|
|
|
|
typedef struct _lpar lpar_t;
|
|
|
|
typedef lpar_t *lparPtr;
|
|
|
|
struct _lpar {
|
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Struct that holds how many lpars (domains) we're
|
|
|
|
* handling and a pointer to an array of lpar structs
|
|
|
|
* */
|
2009-11-05 16:18:07 +00:00
|
|
|
typedef struct _uuid_table uuid_table_t;
|
|
|
|
typedef uuid_table_t *uuid_tablePtr;
|
|
|
|
struct _uuid_table {
|
2009-07-24 14:17:06 +00:00
|
|
|
int nlpars;
|
|
|
|
lparPtr *lpars;
|
|
|
|
};
|
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
/* This is the main structure of the driver
|
|
|
|
* */
|
|
|
|
typedef struct _phyp_driver phyp_driver_t;
|
|
|
|
typedef phyp_driver_t *phyp_driverPtr;
|
|
|
|
struct _phyp_driver {
|
|
|
|
uuid_tablePtr uuid_table;
|
|
|
|
virCapsPtr caps;
|
|
|
|
int vios_id;
|
|
|
|
char *managed_system;
|
|
|
|
};
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
int phypCheckSPFreeSapce(virConnectPtr conn, int required_size, char *sp);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
int phypGetVIOSPartitionID(virConnectPtr conn);
|
|
|
|
|
|
|
|
virCapsPtr phypCapsInit(void);
|
|
|
|
|
|
|
|
int phypBuildLpar(virConnectPtr conn, virDomainDefPtr def);
|
|
|
|
|
|
|
|
int phypUUIDTable_WriteFile(virConnectPtr conn);
|
|
|
|
|
|
|
|
int phypUUIDTable_ReadFile(virConnectPtr conn);
|
|
|
|
|
|
|
|
int phypUUIDTable_AddLpar(virConnectPtr conn, unsigned char *uuid, int id);
|
|
|
|
|
|
|
|
int phypUUIDTable_RemLpar(virConnectPtr conn, int id);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
int phypUUIDTable_Pull(virConnectPtr conn);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
int phypUUIDTable_Push(virConnectPtr conn);
|
|
|
|
|
|
|
|
int phypUUIDTable_Init(virConnectPtr conn);
|
|
|
|
|
2009-11-05 23:19:16 +00:00
|
|
|
void phypUUIDTable_Free(uuid_tablePtr uuid_table);
|
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
int escape_specialcharacters(char *src, char *dst, size_t dstlen);
|
|
|
|
|
|
|
|
int waitsocket(int socket_fd, LIBSSH2_SESSION * session);
|
|
|
|
|
|
|
|
int phypGetLparUUID(unsigned char *uuid, int lpar_id, virConnectPtr conn);
|
|
|
|
|
|
|
|
int phypRegister(void);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
|
|
|
int phypGetLparState(virConnectPtr conn, unsigned int lpar_id);
|
|
|
|
|
|
|
|
unsigned long phypGetLparMem(virConnectPtr conn,
|
|
|
|
const char *managed_system, int lpar_id,
|
|
|
|
int type);
|
|
|
|
|
|
|
|
unsigned long phypGetLparCPU(virConnectPtr conn,
|
|
|
|
const char *managed_system, int lpar_id);
|
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
unsigned long phypGetLparCPUGeneric(virConnectPtr conn,
|
|
|
|
const char *managed_system,
|
|
|
|
int lpar_id, int type);
|
|
|
|
|
2009-07-24 14:17:06 +00:00
|
|
|
int phypGetRemoteSlot(virConnectPtr conn, const char *managed_system,
|
|
|
|
const char *lpar_name);
|
|
|
|
|
|
|
|
char *phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
|
|
|
|
char *lpar_name);
|
|
|
|
|
|
|
|
int phypDiskType(virConnectPtr conn, char *backing_device);
|
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
LIBSSH2_SESSION *openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
int *internal_socket);
|