2009-07-24 14:17:06 +00:00
|
|
|
/*
|
2011-02-07 21:14:56 +00:00
|
|
|
* Copyright (C) 2010-2011 Red Hat, Inc.
|
2009-07-24 14:17:06 +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 <config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2009-11-05 16:18:07 +00:00
|
|
|
#include <sys/stat.h>
|
2009-07-24 14:17:06 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
2009-09-04 10:08:47 +00:00
|
|
|
#include <libssh2.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netdb.h>
|
2009-11-05 16:18:07 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <domain_event.h>
|
2009-07-24 14:17:06 +00:00
|
|
|
|
|
|
|
#include "internal.h"
|
2010-03-14 20:46:32 +00:00
|
|
|
#include "authhelper.h"
|
2009-07-24 14:17:06 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include "datatypes.h"
|
|
|
|
#include "buf.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "logging.h"
|
|
|
|
#include "driver.h"
|
|
|
|
#include "libvirt/libvirt.h"
|
|
|
|
#include "virterror_internal.h"
|
|
|
|
#include "uuid.h"
|
|
|
|
#include "domain_conf.h"
|
2010-06-24 21:39:27 +00:00
|
|
|
#include "storage_conf.h"
|
2009-11-05 16:18:07 +00:00
|
|
|
#include "nodeinfo.h"
|
2010-11-09 20:48:48 +00:00
|
|
|
#include "files.h"
|
2011-03-28 20:07:20 +00:00
|
|
|
#include "interface_conf.h"
|
2009-07-24 14:17:06 +00:00
|
|
|
|
|
|
|
#include "phyp_driver.h"
|
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_PHYP
|
|
|
|
|
2010-04-03 00:49:39 +00:00
|
|
|
#define PHYP_ERROR(code, ...) \
|
|
|
|
virReportErrorHelper(NULL, VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \
|
2010-03-01 23:38:28 +00:00
|
|
|
__LINE__, __VA_ARGS__)
|
2009-11-06 02:19:22 +00:00
|
|
|
|
2009-07-24 14:17:06 +00:00
|
|
|
/*
|
|
|
|
* URI: phyp://user@[hmc|ivm]/managed_system
|
|
|
|
* */
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static unsigned const int HMC = 0;
|
|
|
|
static unsigned const int IVM = 127;
|
2011-03-28 20:07:20 +00:00
|
|
|
static unsigned const int PHYP_IFACENAME_SIZE = 24;
|
|
|
|
static unsigned const int PHYP_MAC_SIZE= 12;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
waitsocket(int socket_fd, LIBSSH2_SESSION * session)
|
|
|
|
{
|
|
|
|
struct timeval timeout;
|
|
|
|
int rc;
|
|
|
|
fd_set fd;
|
|
|
|
fd_set *writefd = NULL;
|
|
|
|
fd_set *readfd = NULL;
|
|
|
|
int dir;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
timeout.tv_sec = 0;
|
|
|
|
timeout.tv_usec = 1000;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
FD_ZERO(&fd);
|
2009-08-20 10:32:19 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
FD_SET(socket_fd, &fd);
|
2009-08-20 10:32:19 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* now make sure we wait in the correct direction */
|
|
|
|
dir = libssh2_session_block_directions(session);
|
2009-08-20 11:59:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (dir & LIBSSH2_SESSION_BLOCK_INBOUND)
|
|
|
|
readfd = &fd;
|
2009-08-20 10:32:19 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
|
|
|
|
writefd = &fd;
|
2009-11-05 23:19:16 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* this function is the layer that manipulates the ssh channel itself
|
|
|
|
* and executes the commands on the remote machine */
|
|
|
|
static char *
|
2011-04-09 09:59:08 +00:00
|
|
|
phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status,
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virConnectPtr conn)
|
|
|
|
{
|
|
|
|
LIBSSH2_CHANNEL *channel;
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
virBuffer tex_ret = VIR_BUFFER_INITIALIZER;
|
2011-04-03 09:21:18 +00:00
|
|
|
char *buffer = NULL;
|
|
|
|
size_t buffer_size = 16384;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
int exitcode;
|
|
|
|
int bytecount = 0;
|
|
|
|
int sock = connection_data->sock;
|
|
|
|
int rc = 0;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-03 09:21:18 +00:00
|
|
|
if (VIR_ALLOC_N(buffer, buffer_size) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* Exec non-blocking on the remove host */
|
|
|
|
while ((channel = libssh2_channel_open_session(session)) == NULL &&
|
|
|
|
libssh2_session_last_error(session, NULL, NULL, 0) ==
|
|
|
|
LIBSSH2_ERROR_EAGAIN) {
|
|
|
|
waitsocket(sock, session);
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (channel == NULL) {
|
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
2010-03-14 20:46:32 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
while ((rc = libssh2_channel_exec(channel, cmd)) ==
|
|
|
|
LIBSSH2_ERROR_EAGAIN) {
|
|
|
|
waitsocket(sock, session);
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (rc != 0) {
|
|
|
|
goto err;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
for (;;) {
|
|
|
|
/* loop until we block */
|
|
|
|
do {
|
2011-04-03 09:21:18 +00:00
|
|
|
rc = libssh2_channel_read(channel, buffer, buffer_size);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (rc > 0) {
|
|
|
|
bytecount += rc;
|
2011-04-14 19:27:47 +00:00
|
|
|
virBufferAdd(&tex_ret, buffer, -1);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (rc > 0);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* this is due to blocking that would occur otherwise so we loop on
|
|
|
|
* this condition */
|
|
|
|
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
|
|
|
waitsocket(sock, session);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2010-06-16 20:33:27 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
exitcode = 127;
|
2009-08-20 10:32:19 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
while ((rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN) {
|
|
|
|
waitsocket(sock, session);
|
2009-11-05 23:19:16 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (rc == 0) {
|
|
|
|
exitcode = libssh2_channel_get_exit_status(channel);
|
2009-11-05 23:19:16 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
(*exit_status) = exitcode;
|
|
|
|
libssh2_channel_free(channel);
|
|
|
|
channel = NULL;
|
|
|
|
goto exit;
|
2009-08-20 10:32:19 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
err:
|
|
|
|
(*exit_status) = SSH_CMD_ERR;
|
|
|
|
virBufferFreeAndReset(&tex_ret);
|
2011-04-03 09:21:18 +00:00
|
|
|
VIR_FREE(buffer);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
exit:
|
2011-04-03 09:21:18 +00:00
|
|
|
VIR_FREE(buffer);
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virBufferError(&tex_ret)) {
|
|
|
|
virBufferFreeAndReset(&tex_ret);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return virBufferContentAndReset(&tex_ret);
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypGetSystemType(virConnectPtr conn)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
2009-09-04 10:08:47 +00:00
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virAsprintf(&cmd, "lshmc -V") < 0) {
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:09 +00:00
|
|
|
return -1;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
return exit_status;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
static int
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypGetVIOSPartitionID(virConnectPtr conn)
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
|
|
|
int id = -1;
|
|
|
|
char *char_ptr;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lssyscfg");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
2010-06-24 22:25:56 +00:00
|
|
|
virBufferAddLit(&buf, " -r lpar -F lpar_id,lpar_env"
|
|
|
|
"|sed -n '/vioserver/ {\n s/,.*$//\n p\n}'");
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &id) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-03-14 20:46:32 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2010-03-14 20:46:32 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return id;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2010-03-14 20:46:32 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static virCapsPtr
|
|
|
|
phypCapsInit(void)
|
|
|
|
{
|
|
|
|
struct utsname utsname;
|
|
|
|
virCapsPtr caps;
|
|
|
|
virCapsGuestPtr guest;
|
2010-03-14 20:46:32 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
uname(&utsname);
|
2009-09-04 10:08:47 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((caps = virCapabilitiesNew(utsname.machine, 0, 0)) == NULL)
|
|
|
|
goto no_memory;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* Some machines have problematic NUMA toplogy causing
|
|
|
|
* unexpected failures. We don't want to break the QEMU
|
|
|
|
* driver in this scenario, so log errors & carry on
|
|
|
|
*/
|
|
|
|
if (nodeCapsInitNUMA(caps) < 0) {
|
|
|
|
virCapabilitiesFreeNUMAInfo(caps);
|
|
|
|
VIR_WARN0
|
|
|
|
("Failed to query host NUMA topology, disabling NUMA capabilities");
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* XXX shouldn't 'borrow' KVM's prefix */
|
|
|
|
virCapabilitiesSetMacPrefix(caps, (unsigned char[]) {
|
|
|
|
0x52, 0x54, 0x00});
|
2009-09-04 10:08:47 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps,
|
|
|
|
"linux",
|
|
|
|
utsname.machine,
|
|
|
|
sizeof(int) == 4 ? 32 : 8,
|
|
|
|
NULL, NULL, 0, NULL)) == NULL)
|
|
|
|
goto no_memory;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"phyp", NULL, NULL, 0, NULL) == NULL)
|
|
|
|
goto no_memory;
|
2009-11-10 12:15:34 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return caps;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
no_memory:
|
|
|
|
virCapabilitiesFree(caps);
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* This is a generic function that won't be used directly by
|
|
|
|
* libvirt api. The function returns the number of domains
|
|
|
|
* in different states: Running, Not Activated and all:
|
|
|
|
*
|
|
|
|
* type: 0 - Running
|
|
|
|
* 1 - Not Activated
|
|
|
|
* * - All
|
|
|
|
* */
|
|
|
|
static int
|
|
|
|
phypNumDomainsGeneric(virConnectPtr conn, unsigned int type)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
2011-04-09 09:59:08 +00:00
|
|
|
int ndom = -1;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char *char_ptr;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
const char *state;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (type == 0)
|
|
|
|
state = "|grep Running";
|
|
|
|
else if (type == 1) {
|
|
|
|
if (system_type == HMC) {
|
|
|
|
state = "|grep \"Not Activated\"";
|
|
|
|
} else {
|
|
|
|
state = "|grep \"Open Firmware\"";
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
} else
|
|
|
|
state = " ";
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lssyscfg -r lpar");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -F lpar_id,state %s |grep -c '^[0-9]*'",
|
|
|
|
state);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-10 12:15:34 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-10 12:15:34 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &ndom) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-10 12:15:34 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return ndom;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* This is a generic function that won't be used directly by
|
|
|
|
* libvirt api. The function returns the ids of domains
|
|
|
|
* in different states: Running, and all:
|
|
|
|
*
|
|
|
|
* type: 0 - Running
|
|
|
|
* 1 - all
|
|
|
|
* */
|
|
|
|
static int
|
|
|
|
phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids,
|
|
|
|
unsigned int type)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
2009-09-04 10:08:47 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
2010-06-16 20:33:27 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
2010-06-16 20:33:27 +00:00
|
|
|
int system_type = phyp_driver->system_type;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char *managed_system = phyp_driver->managed_system;
|
2009-07-24 14:17:06 +00:00
|
|
|
int exit_status = 0;
|
2010-07-15 22:37:48 +00:00
|
|
|
int got = -1;
|
2009-11-05 23:19:16 +00:00
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
2010-07-15 22:37:48 +00:00
|
|
|
char *line, *next_line;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
const char *state;
|
2010-06-16 20:33:27 +00:00
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (type == 0)
|
|
|
|
state = "|grep Running";
|
|
|
|
else
|
|
|
|
state = " ";
|
|
|
|
|
2010-06-16 20:33:27 +00:00
|
|
|
virBufferAddLit(&buf, "lssyscfg -r lpar");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferVSprintf(&buf, " -F lpar_id,state %s | sed -e 's/,.*$//'",
|
|
|
|
state);
|
2010-06-16 20:33:27 +00:00
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2010-06-16 20:33:27 +00:00
|
|
|
return -1;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
2010-06-16 20:33:27 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2009-11-05 23:19:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2009-09-04 10:08:47 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-07-15 22:37:48 +00:00
|
|
|
|
|
|
|
/* I need to parse the textual return in order to get the ids */
|
|
|
|
line = ret;
|
|
|
|
got = 0;
|
|
|
|
while (*line && got < nids) {
|
|
|
|
if (virStrToLong_i(line, &next_line, 10, &ids[got]) == -1) {
|
|
|
|
VIR_ERROR(_("Cannot parse number from '%s'"), line);
|
|
|
|
got = -1;
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2010-07-15 22:37:48 +00:00
|
|
|
got++;
|
|
|
|
line = next_line;
|
|
|
|
while (*line == '\n')
|
|
|
|
line++; /* skip \n */
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2009-07-24 14:17:06 +00:00
|
|
|
VIR_FREE(cmd);
|
2009-11-05 23:19:16 +00:00
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
2010-07-15 22:37:48 +00:00
|
|
|
return got;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypUUIDTable_WriteFile(virConnectPtr conn)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
2009-11-05 16:18:07 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
uuid_tablePtr uuid_table = phyp_driver->uuid_table;
|
2009-07-24 14:17:06 +00:00
|
|
|
unsigned int i = 0;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
int fd = -1;
|
|
|
|
char local_file[] = "./uuid_table";
|
|
|
|
|
|
|
|
if ((fd = creat(local_file, 0755)) == -1)
|
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
for (i = 0; i < uuid_table->nlpars; i++) {
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (safewrite(fd, &uuid_table->lpars[i]->id,
|
|
|
|
sizeof(uuid_table->lpars[i]->id)) !=
|
|
|
|
sizeof(uuid_table->lpars[i]->id)) {
|
|
|
|
VIR_ERROR0(_("Unable to write information to local file."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (safewrite(fd, uuid_table->lpars[i]->uuid, VIR_UUID_BUFLEN) !=
|
|
|
|
VIR_UUID_BUFLEN) {
|
|
|
|
VIR_ERROR0(_("Unable to write information to local file."));
|
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-09 20:48:48 +00:00
|
|
|
if (VIR_CLOSE(fd) < 0) {
|
|
|
|
virReportSystemError(errno, _("Could not close %s"),
|
|
|
|
local_file);
|
|
|
|
goto err;
|
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2010-11-09 20:48:48 +00:00
|
|
|
VIR_FORCE_CLOSE(fd);
|
2009-07-24 14:17:06 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypUUIDTable_Push(virConnectPtr conn)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
2009-09-04 10:08:47 +00:00
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
LIBSSH2_CHANNEL *channel = NULL;
|
|
|
|
virBuffer username = VIR_BUFFER_INITIALIZER;
|
|
|
|
struct stat local_fileinfo;
|
|
|
|
char buffer[1024];
|
|
|
|
int rc = 0;
|
|
|
|
FILE *fd;
|
|
|
|
size_t nread, sent;
|
|
|
|
char *ptr;
|
|
|
|
char local_file[] = "./uuid_table";
|
|
|
|
char *remote_file = NULL;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (conn->uri->user != NULL) {
|
2011-04-14 19:27:47 +00:00
|
|
|
virBufferAdd(&username, conn->uri->user, -1);
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virBufferError(&username)) {
|
|
|
|
virBufferFreeAndReset(&username);
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virAsprintf
|
|
|
|
(&remote_file, "/home/%s/libvirt_uuid_table",
|
|
|
|
virBufferContentAndReset(&username))
|
|
|
|
< 0) {
|
2010-06-16 20:33:27 +00:00
|
|
|
virReportOOMError();
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (stat(local_file, &local_fileinfo) == -1) {
|
|
|
|
VIR_WARN0("Unable to stat local file.");
|
|
|
|
goto err;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (!(fd = fopen(local_file, "rb"))) {
|
|
|
|
VIR_WARN0("Unable to open local file.");
|
2009-07-24 14:17:06 +00:00
|
|
|
goto err;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
do {
|
|
|
|
channel =
|
|
|
|
libssh2_scp_send(session, remote_file,
|
|
|
|
0x1FF & local_fileinfo.st_mode,
|
|
|
|
(unsigned long) local_fileinfo.st_size);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((!channel) && (libssh2_session_last_errno(session) !=
|
|
|
|
LIBSSH2_ERROR_EAGAIN))
|
|
|
|
goto err;
|
|
|
|
} while (!channel);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
do {
|
|
|
|
nread = fread(buffer, 1, sizeof(buffer), fd);
|
|
|
|
if (nread <= 0) {
|
|
|
|
if (feof(fd)) {
|
|
|
|
/* end of file */
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
VIR_ERROR(_("Failed to read from %s"), local_file);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ptr = buffer;
|
|
|
|
sent = 0;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
do {
|
|
|
|
/* write the same data over and over, until error or completion */
|
|
|
|
rc = libssh2_channel_write(channel, ptr, nread);
|
|
|
|
if (LIBSSH2_ERROR_EAGAIN == rc) { /* must loop around */
|
|
|
|
continue;
|
|
|
|
} else if (rc > 0) {
|
|
|
|
/* rc indicates how many bytes were written this time */
|
|
|
|
sent += rc;
|
|
|
|
}
|
|
|
|
ptr += sent;
|
|
|
|
nread -= sent;
|
|
|
|
} while (rc > 0 && sent < nread);
|
|
|
|
} while (1);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (channel) {
|
|
|
|
libssh2_channel_send_eof(channel);
|
|
|
|
libssh2_channel_wait_eof(channel);
|
|
|
|
libssh2_channel_wait_closed(channel);
|
|
|
|
libssh2_channel_free(channel);
|
|
|
|
channel = NULL;
|
|
|
|
}
|
|
|
|
virBufferFreeAndReset(&username);
|
2009-07-24 14:17:06 +00:00
|
|
|
return 0;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
err:
|
|
|
|
if (channel) {
|
|
|
|
libssh2_channel_send_eof(channel);
|
|
|
|
libssh2_channel_wait_eof(channel);
|
|
|
|
libssh2_channel_wait_closed(channel);
|
|
|
|
libssh2_channel_free(channel);
|
|
|
|
channel = NULL;
|
|
|
|
}
|
|
|
|
return -1;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypUUIDTable_RemLpar(virConnectPtr conn, int id)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
2010-06-16 20:33:27 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
uuid_tablePtr uuid_table = phyp_driver->uuid_table;
|
|
|
|
unsigned int i = 0;
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
for (i = 0; i <= uuid_table->nlpars; i++) {
|
|
|
|
if (uuid_table->lpars[i]->id == id) {
|
|
|
|
uuid_table->lpars[i]->id = -1;
|
|
|
|
memset(uuid_table->lpars[i]->uuid, 0, VIR_UUID_BUFLEN);
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypUUIDTable_WriteFile(conn) == -1)
|
2009-07-24 14:17:06 +00:00
|
|
|
goto err;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypUUIDTable_Push(conn) == -1)
|
2009-07-24 14:17:06 +00:00
|
|
|
goto err;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return 0;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
|
|
|
err:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return -1;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypUUIDTable_AddLpar(virConnectPtr conn, unsigned char *uuid, int id)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
2010-06-16 20:33:27 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
uuid_tablePtr uuid_table = phyp_driver->uuid_table;
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
uuid_table->nlpars++;
|
|
|
|
unsigned int i = uuid_table->nlpars;
|
|
|
|
i--;
|
|
|
|
|
|
|
|
if (VIR_REALLOC_N(uuid_table->lpars, uuid_table->nlpars) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (VIR_ALLOC(uuid_table->lpars[i]) < 0) {
|
|
|
|
virReportOOMError();
|
2009-07-24 14:17:06 +00:00
|
|
|
goto err;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
uuid_table->lpars[i]->id = id;
|
|
|
|
memmove(uuid_table->lpars[i]->uuid, uuid, VIR_UUID_BUFLEN);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypUUIDTable_WriteFile(conn) == -1)
|
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypUUIDTable_Push(conn) == -1)
|
2009-07-24 14:17:06 +00:00
|
|
|
goto err;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return 0;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
|
|
|
err:
|
2009-11-05 16:18:07 +00:00
|
|
|
return -1;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypUUIDTable_ReadFile(virConnectPtr conn)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
2010-06-16 20:33:27 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
uuid_tablePtr uuid_table = phyp_driver->uuid_table;
|
|
|
|
unsigned int i = 0;
|
|
|
|
int fd = -1;
|
|
|
|
char local_file[] = "./uuid_table";
|
|
|
|
int rc = 0;
|
|
|
|
int id;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((fd = open(local_file, O_RDONLY)) == -1) {
|
|
|
|
VIR_WARN0("Unable to write information to local file.");
|
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* Creating a new data base and writing to local file */
|
|
|
|
if (VIR_ALLOC_N(uuid_table->lpars, uuid_table->nlpars) >= 0) {
|
|
|
|
for (i = 0; i < uuid_table->nlpars; i++) {
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
rc = read(fd, &id, sizeof(int));
|
|
|
|
if (rc == sizeof(int)) {
|
|
|
|
if (VIR_ALLOC(uuid_table->lpars[i]) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
uuid_table->lpars[i]->id = id;
|
|
|
|
} else {
|
|
|
|
VIR_WARN0
|
|
|
|
("Unable to read from information to local file.");
|
|
|
|
goto err;
|
|
|
|
}
|
2009-11-05 23:19:16 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
rc = read(fd, uuid_table->lpars[i]->uuid, VIR_UUID_BUFLEN);
|
|
|
|
if (rc != VIR_UUID_BUFLEN) {
|
|
|
|
VIR_WARN0("Unable to read information to local file.");
|
|
|
|
goto err;
|
|
|
|
}
|
2009-11-05 23:19:16 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
} else
|
|
|
|
virReportOOMError();
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2010-11-09 20:48:48 +00:00
|
|
|
VIR_FORCE_CLOSE(fd);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return 0;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
|
|
|
err:
|
2010-11-09 20:48:48 +00:00
|
|
|
VIR_FORCE_CLOSE(fd);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return -1;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypUUIDTable_Pull(virConnectPtr conn)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
2009-09-04 10:08:47 +00:00
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
LIBSSH2_CHANNEL *channel = NULL;
|
|
|
|
virBuffer username = VIR_BUFFER_INITIALIZER;
|
|
|
|
struct stat fileinfo;
|
|
|
|
char buffer[1024];
|
|
|
|
int rc = 0;
|
|
|
|
int fd;
|
|
|
|
int got = 0;
|
|
|
|
int amount = 0;
|
|
|
|
int total = 0;
|
|
|
|
int sock = 0;
|
|
|
|
char local_file[] = "./uuid_table";
|
|
|
|
char *remote_file = NULL;
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (conn->uri->user != NULL) {
|
2011-04-14 19:27:47 +00:00
|
|
|
virBufferAdd(&username, conn->uri->user, -1);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virBufferError(&username)) {
|
|
|
|
virBufferFreeAndReset(&username);
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virAsprintf
|
|
|
|
(&remote_file, "/home/%s/libvirt_uuid_table",
|
|
|
|
virBufferContentAndReset(&username))
|
|
|
|
< 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* Trying to stat the remote file. */
|
|
|
|
do {
|
|
|
|
channel = libssh2_scp_recv(session, remote_file, &fileinfo);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (!channel) {
|
|
|
|
if (libssh2_session_last_errno(session) !=
|
|
|
|
LIBSSH2_ERROR_EAGAIN) {
|
|
|
|
goto err;;
|
|
|
|
} else {
|
|
|
|
waitsocket(sock, session);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!channel);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* Creating a new data base based on remote file */
|
|
|
|
if ((fd = creat(local_file, 0755)) == -1)
|
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* Request a file via SCP */
|
|
|
|
while (got < fileinfo.st_size) {
|
|
|
|
do {
|
|
|
|
amount = sizeof(buffer);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((fileinfo.st_size - got) < amount) {
|
|
|
|
amount = fileinfo.st_size - got;
|
|
|
|
}
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
rc = libssh2_channel_read(channel, buffer, amount);
|
|
|
|
if (rc > 0) {
|
|
|
|
if (safewrite(fd, buffer, rc) != rc)
|
|
|
|
VIR_WARN0
|
|
|
|
("Unable to write information to local file.");
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
got += rc;
|
|
|
|
total += rc;
|
|
|
|
}
|
|
|
|
} while (rc > 0);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((rc == LIBSSH2_ERROR_EAGAIN)
|
|
|
|
&& (got < fileinfo.st_size)) {
|
|
|
|
/* this is due to blocking that would occur otherwise
|
|
|
|
* so we loop on this condition */
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
waitsocket(sock, session); /* now we wait */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-11-09 20:48:48 +00:00
|
|
|
if (VIR_CLOSE(fd) < 0) {
|
|
|
|
virReportSystemError(errno, _("Could not close %s"),
|
|
|
|
local_file);
|
|
|
|
goto err;
|
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
goto exit;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
exit:
|
|
|
|
if (channel) {
|
|
|
|
libssh2_channel_send_eof(channel);
|
|
|
|
libssh2_channel_wait_eof(channel);
|
|
|
|
libssh2_channel_wait_closed(channel);
|
|
|
|
libssh2_channel_free(channel);
|
|
|
|
channel = NULL;
|
|
|
|
}
|
|
|
|
virBufferFreeAndReset(&username);
|
|
|
|
return 0;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
|
|
|
err:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (channel) {
|
|
|
|
libssh2_channel_send_eof(channel);
|
|
|
|
libssh2_channel_wait_eof(channel);
|
|
|
|
libssh2_channel_wait_closed(channel);
|
|
|
|
libssh2_channel_free(channel);
|
|
|
|
channel = NULL;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypUUIDTable_Init(virConnectPtr conn)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
2011-04-14 17:32:39 +00:00
|
|
|
uuid_tablePtr uuid_table = NULL;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phyp_driverPtr phyp_driver;
|
|
|
|
int nids_numdomains = 0;
|
|
|
|
int nids_listdomains = 0;
|
|
|
|
int *ids = NULL;
|
|
|
|
unsigned int i = 0;
|
2011-04-14 17:32:39 +00:00
|
|
|
int ret = -1;
|
|
|
|
bool table_created = false;
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((nids_numdomains = phypNumDomainsGeneric(conn, 2)) < 0)
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
if (VIR_ALLOC_N(ids, nids_numdomains) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((nids_listdomains =
|
|
|
|
phypListDomainsGeneric(conn, ids, nids_numdomains, 1)) < 0)
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* exit early if there are no domains */
|
2011-04-14 17:32:39 +00:00
|
|
|
if (nids_numdomains == 0 && nids_listdomains == 0) {
|
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (nids_numdomains != nids_listdomains) {
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_ERROR0(_("Unable to determine number of domains."));
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phyp_driver = conn->privateData;
|
|
|
|
uuid_table = phyp_driver->uuid_table;
|
|
|
|
uuid_table->nlpars = nids_listdomains;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* try to get the table from server */
|
|
|
|
if (phypUUIDTable_Pull(conn) == -1) {
|
|
|
|
/* file not found in the server, creating a new one */
|
2011-04-14 17:32:39 +00:00
|
|
|
table_created = true;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (VIR_ALLOC_N(uuid_table->lpars, uuid_table->nlpars) >= 0) {
|
|
|
|
for (i = 0; i < uuid_table->nlpars; i++) {
|
|
|
|
if (VIR_ALLOC(uuid_table->lpars[i]) < 0) {
|
|
|
|
virReportOOMError();
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
|
|
|
uuid_table->lpars[i]->id = ids[i];
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virUUIDGenerate(uuid_table->lpars[i]->uuid) < 0)
|
|
|
|
VIR_WARN("Unable to generate UUID for domain %d",
|
|
|
|
ids[i]);
|
|
|
|
}
|
2010-06-16 20:33:27 +00:00
|
|
|
} else {
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virReportOOMError();
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
2010-06-16 20:33:27 +00:00
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypUUIDTable_WriteFile(conn) == -1)
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypUUIDTable_Push(conn) == -1)
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
} else {
|
|
|
|
if (phypUUIDTable_ReadFile(conn) == -1)
|
2011-04-14 17:32:39 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2011-04-14 17:32:39 +00:00
|
|
|
ret = 0;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2011-04-14 17:32:39 +00:00
|
|
|
cleanup:
|
|
|
|
if (ret < 0 && table_created) {
|
|
|
|
for (i = 0; i < uuid_table->nlpars; i++) {
|
|
|
|
VIR_FREE(uuid_table->lpars[i]);
|
|
|
|
}
|
|
|
|
VIR_FREE(uuid_table->lpars);
|
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(ids);
|
2011-04-14 17:32:39 +00:00
|
|
|
return ret;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static void
|
|
|
|
phypUUIDTable_Free(uuid_tablePtr uuid_table)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
int i;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (uuid_table == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < uuid_table->nlpars; i++)
|
|
|
|
VIR_FREE(uuid_table->lpars[i]);
|
|
|
|
|
|
|
|
VIR_FREE(uuid_table->lpars);
|
|
|
|
VIR_FREE(uuid_table);
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:10 +00:00
|
|
|
#define SPECIALCHARACTER_CASES \
|
|
|
|
case '&': case ';': case '`': case '@': case '"': case '|': case '*': \
|
|
|
|
case '?': case '~': case '<': case '>': case '^': case '(': case ')': \
|
|
|
|
case '[': case ']': case '{': case '}': case '$': case '%': case '#': \
|
|
|
|
case '\\': case '\n': case '\r': case '\t':
|
|
|
|
|
|
|
|
static bool
|
|
|
|
contains_specialcharacters(const char *src)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
size_t len = strlen(src);
|
2011-04-09 09:59:10 +00:00
|
|
|
size_t i = 0;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (len == 0)
|
2011-04-09 09:59:10 +00:00
|
|
|
return false;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
switch (src[i]) {
|
2011-04-09 09:59:10 +00:00
|
|
|
SPECIALCHARACTER_CASES
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
continue;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2011-04-09 09:59:10 +00:00
|
|
|
static char *
|
|
|
|
escape_specialcharacters(const char *src)
|
|
|
|
{
|
|
|
|
size_t len = strlen(src);
|
|
|
|
size_t i = 0, j = 0;
|
|
|
|
char *dst;
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(dst, len + 1) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
switch (src[i]) {
|
|
|
|
SPECIALCHARACTER_CASES
|
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
dst[j] = src[i];
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dst[j] = '\0';
|
|
|
|
|
|
|
|
return dst;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static LIBSSH2_SESSION *
|
|
|
|
openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
int *internal_socket)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
LIBSSH2_SESSION *session;
|
|
|
|
const char *hostname = conn->uri->server;
|
|
|
|
char *username = NULL;
|
|
|
|
char *password = NULL;
|
|
|
|
int sock;
|
|
|
|
int rc;
|
|
|
|
struct addrinfo *ai = NULL, *cur;
|
|
|
|
struct addrinfo hints;
|
|
|
|
int ret;
|
|
|
|
char *pubkey = NULL;
|
|
|
|
char *pvtkey = NULL;
|
|
|
|
char *userhome = virGetUserDirectory(geteuid());
|
|
|
|
struct stat pvt_stat, pub_stat;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (userhome == NULL)
|
|
|
|
goto err;
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virAsprintf(&pubkey, "%s/.ssh/id_rsa.pub", userhome) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virAsprintf(&pvtkey, "%s/.ssh/id_rsa", userhome) < 0) {
|
|
|
|
virReportOOMError();
|
2009-07-24 14:17:06 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (conn->uri->user != NULL) {
|
|
|
|
username = strdup(conn->uri->user);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (username == NULL) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (auth == NULL || auth->cb == NULL) {
|
|
|
|
PHYP_ERROR(VIR_ERR_AUTH_FAILED,
|
|
|
|
"%s", _("No authentication callback provided."));
|
|
|
|
goto err;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
username = virRequestUsername(auth, NULL, conn->uri->server);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (username == NULL) {
|
|
|
|
PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("Username request failed"));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
hints.ai_protocol = 0;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = getaddrinfo(hostname, "22", &hints, &ai);
|
|
|
|
if (ret != 0) {
|
|
|
|
PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Error while getting %s address info"), hostname);
|
|
|
|
goto err;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cur = ai;
|
|
|
|
while (cur != NULL) {
|
|
|
|
sock = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
|
|
|
|
if (sock >= 0) {
|
|
|
|
if (connect(sock, cur->ai_addr, cur->ai_addrlen) == 0) {
|
|
|
|
goto connected;
|
|
|
|
}
|
2010-11-09 20:48:48 +00:00
|
|
|
VIR_FORCE_CLOSE(sock);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
|
|
|
cur = cur->ai_next;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Failed to connect to %s"), hostname);
|
|
|
|
freeaddrinfo(ai);
|
|
|
|
goto err;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
connected:
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
(*internal_socket) = sock;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* Create a session instance */
|
|
|
|
session = libssh2_session_init();
|
|
|
|
if (!session)
|
2009-07-24 14:17:06 +00:00
|
|
|
goto err;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* tell libssh2 we want it all done non-blocking */
|
|
|
|
libssh2_session_set_blocking(session, 0);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
while ((rc = libssh2_session_startup(session, sock)) ==
|
|
|
|
LIBSSH2_ERROR_EAGAIN) ;
|
|
|
|
if (rc) {
|
|
|
|
PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Failure establishing SSH session."));
|
|
|
|
goto disconnect;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* Trying authentication by pubkey */
|
|
|
|
if (stat(pvtkey, &pvt_stat) || stat(pubkey, &pub_stat)) {
|
|
|
|
rc = LIBSSH2_ERROR_SOCKET_NONE;
|
|
|
|
goto keyboard_interactive;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
while ((rc =
|
|
|
|
libssh2_userauth_publickey_fromfile(session, username,
|
|
|
|
pubkey,
|
|
|
|
pvtkey,
|
|
|
|
NULL)) ==
|
|
|
|
LIBSSH2_ERROR_EAGAIN) ;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
keyboard_interactive:
|
|
|
|
if (rc == LIBSSH2_ERROR_SOCKET_NONE
|
|
|
|
|| rc == LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED
|
|
|
|
|| rc == LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED) {
|
|
|
|
if (auth == NULL || auth->cb == NULL) {
|
|
|
|
PHYP_ERROR(VIR_ERR_AUTH_FAILED,
|
|
|
|
"%s", _("No authentication callback provided."));
|
|
|
|
goto disconnect;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
password = virRequestPassword(auth, username, conn->uri->server);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (password == NULL) {
|
|
|
|
PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("Password request failed"));
|
|
|
|
goto disconnect;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
while ((rc =
|
|
|
|
libssh2_userauth_password(session, username,
|
|
|
|
password)) ==
|
|
|
|
LIBSSH2_ERROR_EAGAIN) ;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (rc) {
|
|
|
|
PHYP_ERROR(VIR_ERR_AUTH_FAILED,
|
|
|
|
"%s", _("Authentication failed"));
|
|
|
|
goto disconnect;
|
|
|
|
} else
|
|
|
|
goto exit;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
} else if (rc == LIBSSH2_ERROR_NONE) {
|
|
|
|
goto exit;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
} else if (rc == LIBSSH2_ERROR_ALLOC || rc == LIBSSH2_ERROR_SOCKET_SEND
|
|
|
|
|| rc == LIBSSH2_ERROR_SOCKET_TIMEOUT) {
|
2009-07-24 14:17:06 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
disconnect:
|
|
|
|
libssh2_session_disconnect(session, "Disconnecting...");
|
|
|
|
libssh2_session_free(session);
|
2009-11-05 16:18:07 +00:00
|
|
|
err:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(userhome);
|
|
|
|
VIR_FREE(pubkey);
|
|
|
|
VIR_FREE(pvtkey);
|
|
|
|
VIR_FREE(username);
|
|
|
|
VIR_FREE(password);
|
2009-11-05 16:18:07 +00:00
|
|
|
return NULL;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
VIR_FREE(userhome);
|
|
|
|
VIR_FREE(pubkey);
|
|
|
|
VIR_FREE(pvtkey);
|
|
|
|
VIR_FREE(username);
|
|
|
|
VIR_FREE(password);
|
|
|
|
return session;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static virDrvOpenStatus
|
|
|
|
phypOpen(virConnectPtr conn,
|
|
|
|
virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
LIBSSH2_SESSION *session = NULL;
|
|
|
|
ConnectionData *connection_data = NULL;
|
|
|
|
int internal_socket;
|
|
|
|
uuid_tablePtr uuid_table = NULL;
|
|
|
|
phyp_driverPtr phyp_driver = NULL;
|
|
|
|
char *char_ptr;
|
|
|
|
char *managed_system = NULL;
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (!conn || !conn->uri)
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
if (conn->uri->scheme == NULL || STRNEQ(conn->uri->scheme, "phyp"))
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
if (conn->uri->server == NULL) {
|
|
|
|
PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Missing server name in phyp:// URI"));
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC(phyp_driver) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
goto failure;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (VIR_ALLOC(uuid_table) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto failure;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (VIR_ALLOC(connection_data) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto failure;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (conn->uri->path) {
|
|
|
|
/* need to shift one byte in order to remove the first "/" of URI component */
|
|
|
|
if (conn->uri->path[0] == '/')
|
|
|
|
managed_system = strdup(conn->uri->path + 1);
|
|
|
|
else
|
|
|
|
managed_system = strdup(conn->uri->path);
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (!managed_system) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* here we are handling only the first component of the path,
|
|
|
|
* so skipping the second:
|
|
|
|
* */
|
|
|
|
char_ptr = strchr(managed_system, '/');
|
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
2011-04-09 09:59:10 +00:00
|
|
|
if (contains_specialcharacters(conn->uri->path)) {
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s",
|
|
|
|
_("Error parsing 'path'. Invalid characters."));
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((session = openSSHSession(conn, auth, &internal_socket)) == NULL) {
|
|
|
|
PHYP_ERROR(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Error while opening SSH session."));
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
connection_data->session = session;
|
|
|
|
|
|
|
|
uuid_table->nlpars = 0;
|
|
|
|
uuid_table->lpars = NULL;
|
|
|
|
|
|
|
|
if (conn->uri->path)
|
|
|
|
phyp_driver->managed_system = managed_system;
|
|
|
|
|
|
|
|
phyp_driver->uuid_table = uuid_table;
|
|
|
|
if ((phyp_driver->caps = phypCapsInit()) == NULL) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
goto failure;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
conn->privateData = phyp_driver;
|
|
|
|
conn->networkPrivateData = connection_data;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((phyp_driver->system_type = phypGetSystemType(conn)) == -1)
|
|
|
|
goto failure;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypUUIDTable_Init(conn) == -1)
|
|
|
|
goto failure;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phyp_driver->system_type == HMC) {
|
|
|
|
if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1)
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
|
|
|
|
failure:
|
|
|
|
if (phyp_driver != NULL) {
|
|
|
|
virCapabilitiesFree(phyp_driver->caps);
|
|
|
|
VIR_FREE(phyp_driver->managed_system);
|
|
|
|
VIR_FREE(phyp_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
phypUUIDTable_Free(uuid_table);
|
|
|
|
|
|
|
|
if (session != NULL) {
|
|
|
|
libssh2_session_disconnect(session, "Disconnecting...");
|
|
|
|
libssh2_session_free(session);
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_FREE(connection_data);
|
|
|
|
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypClose(virConnectPtr conn)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
libssh2_session_disconnect(session, "Disconnecting...");
|
|
|
|
libssh2_session_free(session);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virCapabilitiesFree(phyp_driver->caps);
|
|
|
|
phypUUIDTable_Free(phyp_driver->uuid_table);
|
|
|
|
VIR_FREE(phyp_driver->managed_system);
|
|
|
|
VIR_FREE(phyp_driver);
|
|
|
|
VIR_FREE(connection_data);
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* Phyp uses an SSH tunnel, so is always encrypted */
|
|
|
|
return 1;
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
phypIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* Phyp uses an SSH tunnel, so is always secure */
|
|
|
|
return 1;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 07:43:15 +00:00
|
|
|
static int
|
|
|
|
phypIsUpdated(virDomainPtr conn ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
/* return the lpar_id given a name and a managed system name */
|
2009-11-05 16:18:07 +00:00
|
|
|
static int
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypGetLparID(LIBSSH2_SESSION * session, const char *managed_system,
|
|
|
|
const char *name, virConnectPtr conn)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
2010-06-16 20:33:27 +00:00
|
|
|
int system_type = phyp_driver->system_type;
|
2009-11-05 16:18:07 +00:00
|
|
|
int exit_status = 0;
|
2011-04-09 09:59:08 +00:00
|
|
|
int lpar_id = -1;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char *char_ptr;
|
2009-11-05 23:19:16 +00:00
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
2010-06-16 20:33:27 +00:00
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lssyscfg -r lpar");
|
2010-06-16 20:33:27 +00:00
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferVSprintf(&buf, " --filter lpar_names=%s -F lpar_id", name);
|
2010-06-16 20:33:27 +00:00
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2010-06-16 20:33:27 +00:00
|
|
|
return -1;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
2010-06-16 20:33:27 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &lpar_id) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2009-11-05 16:18:07 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return lpar_id;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* return the lpar name given a lpar_id and a managed system name */
|
|
|
|
static char *
|
|
|
|
phypGetLparNAME(LIBSSH2_SESSION * session, const char *managed_system,
|
|
|
|
unsigned int lpar_id, virConnectPtr conn)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char *char_ptr;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lssyscfg -r lpar");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " --filter lpar_ids=%d -F name", lpar_id);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
if (exit_status < 0 || ret == NULL) {
|
|
|
|
VIR_FREE(ret);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return ret;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
/* Search into the uuid_table for a lpar_uuid given a lpar_id
|
|
|
|
* and a managed system name
|
|
|
|
*
|
|
|
|
* return: 0 - record found
|
|
|
|
* -1 - not found
|
|
|
|
* */
|
|
|
|
static int
|
|
|
|
phypGetLparUUID(unsigned char *uuid, int lpar_id, virConnectPtr conn)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
uuid_tablePtr uuid_table = phyp_driver->uuid_table;
|
|
|
|
lparPtr *lpars = uuid_table->lpars;
|
|
|
|
unsigned int i = 0;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
for (i = 0; i < uuid_table->nlpars; i++) {
|
|
|
|
if (lpars[i]->id == lpar_id) {
|
|
|
|
memmove(uuid, lpars[i]->uuid, VIR_UUID_BUFLEN);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return -1;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/*
|
|
|
|
* type:
|
|
|
|
* 0 - maxmem
|
|
|
|
* 1 - memory
|
|
|
|
* */
|
|
|
|
static unsigned long
|
|
|
|
phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id,
|
|
|
|
int type)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *char_ptr;
|
|
|
|
int memory = 0;
|
|
|
|
int exit_status = 0;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (type != 1 && type != 0)
|
|
|
|
return 0;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lshwres");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r mem --level lpar -F %s --filter lpar_ids=%d",
|
|
|
|
type ? "curr_mem" : "curr_max_mem", lpar_id);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return 0;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &memory) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return memory;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static unsigned long
|
|
|
|
phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system,
|
|
|
|
int lpar_id, int type)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
2009-11-05 16:18:07 +00:00
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
2010-06-16 20:33:27 +00:00
|
|
|
int system_type = phyp_driver->system_type;
|
2009-11-05 23:19:16 +00:00
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char *char_ptr;
|
|
|
|
int exit_status = 0;
|
|
|
|
int vcpus = 0;
|
2010-06-16 20:33:27 +00:00
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lshwres");
|
2010-06-16 20:33:27 +00:00
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r proc --level lpar -F %s --filter lpar_ids=%d",
|
|
|
|
type ? "curr_max_procs" : "curr_procs", lpar_id);
|
2010-06-16 20:33:27 +00:00
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2010-06-16 20:33:27 +00:00
|
|
|
return 0;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
2010-06-16 20:33:27 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
char_ptr = strchr(ret, '\n');
|
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &vcpus) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return vcpus;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static unsigned long
|
|
|
|
phypGetLparCPU(virConnectPtr conn, const char *managed_system, int lpar_id)
|
|
|
|
{
|
|
|
|
return phypGetLparCPUGeneric(conn, managed_system, lpar_id, 0);
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
phypDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
{
|
|
|
|
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
|
|
|
PHYP_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return phypGetLparCPUGeneric(dom->conn, managed_system, dom->id, 1);
|
|
|
|
}
|
|
|
|
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
static int
|
|
|
|
phypGetLparCPUMAX(virDomainPtr dom)
|
|
|
|
{
|
|
|
|
return phypDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
|
|
|
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypGetRemoteSlot(virConnectPtr conn, const char *managed_system,
|
|
|
|
const char *lpar_name)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
2009-11-05 16:18:07 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
2010-06-16 20:33:27 +00:00
|
|
|
int system_type = phyp_driver->system_type;
|
2009-11-05 23:19:16 +00:00
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char *char_ptr;
|
2011-04-09 09:59:08 +00:00
|
|
|
int remote_slot = -1;
|
2009-11-05 16:18:07 +00:00
|
|
|
int exit_status = 0;
|
2010-06-16 20:33:27 +00:00
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lshwres");
|
2010-06-16 20:33:27 +00:00
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferVSprintf(&buf, " -r virtualio --rsubtype scsi -F "
|
|
|
|
"remote_slot_num --filter lpar_names=%s", lpar_name);
|
2010-06-16 20:33:27 +00:00
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2010-06-16 20:33:27 +00:00
|
|
|
return -1;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
2010-06-16 20:33:27 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2009-11-05 23:19:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &remote_slot) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2009-11-05 16:18:07 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return remote_slot;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* XXX - is this needed? */
|
|
|
|
static char *phypGetBackingDevice(virConnectPtr, const char *, char *)
|
|
|
|
ATTRIBUTE_UNUSED;
|
|
|
|
static char *
|
|
|
|
phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
|
|
|
|
char *lpar_name)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
2009-11-05 16:18:07 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int remote_slot = 0;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *char_ptr;
|
|
|
|
char *backing_device = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((remote_slot =
|
|
|
|
phypGetRemoteSlot(conn, managed_system, lpar_name)) == -1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -r virtualio --rsubtype scsi -F "
|
|
|
|
"backing_devices --filter slots=%d", remote_slot);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* here is a little trick to deal returns of this kind:
|
|
|
|
*
|
|
|
|
* 0x8100000000000000//lv01
|
|
|
|
*
|
|
|
|
* the information we really need is only lv01, so we
|
|
|
|
* need to skip a lot of things on the string.
|
|
|
|
* */
|
|
|
|
char_ptr = strchr(ret, '/');
|
|
|
|
|
|
|
|
if (char_ptr) {
|
|
|
|
char_ptr++;
|
|
|
|
if (char_ptr[0] == '/')
|
|
|
|
char_ptr++;
|
|
|
|
else
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
backing_device = strdup(char_ptr);
|
|
|
|
|
|
|
|
if (backing_device == NULL) {
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
backing_device = ret;
|
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char_ptr = strchr(backing_device, '\n');
|
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return backing_device;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
phypGetLparProfile(virConnectPtr conn, int lpar_id)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char *char_ptr;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lssyscfg");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r prof --filter lpar_ids=%d -F name|head -n 1",
|
|
|
|
lpar_id);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
if (exit_status < 0 || ret == NULL) {
|
|
|
|
VIR_FREE(ret);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-06-24 21:15:43 +00:00
|
|
|
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return ret;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypGetVIOSNextSlotNumber(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *char_ptr;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *profile = NULL;
|
2011-04-09 09:59:08 +00:00
|
|
|
int slot = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (!(profile = phypGetLparProfile(conn, vios_id))) {
|
|
|
|
VIR_ERROR0(_("Unable to get VIOS profile name."));
|
2011-04-09 09:59:08 +00:00
|
|
|
return -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lssyscfg");
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, " -r prof --filter "
|
|
|
|
"profile_names=%s -F virtual_eth_adapters,"
|
|
|
|
"virtual_opti_pool_id,virtual_scsi_adapters,"
|
|
|
|
"virtual_serial_adapters|sed -e 's/\"//g' -e "
|
|
|
|
"'s/,/\\n/g'|sed -e 's/\\(^[0-9][0-9]\\*\\).*$/\\1/'"
|
|
|
|
"|sort|tail -n 1", profile);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &slot) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
slot += 1;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
|
|
|
VIR_FREE(profile);
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return slot;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypCreateServerSCSIAdapter(virConnectPtr conn)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *profile = NULL;
|
|
|
|
int slot = 0;
|
|
|
|
char *vios_name = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (!
|
|
|
|
(vios_name =
|
|
|
|
phypGetLparNAME(session, managed_system, vios_id, conn))) {
|
|
|
|
VIR_ERROR0(_("Unable to get VIOS name"));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(profile = phypGetLparProfile(conn, vios_id))) {
|
|
|
|
VIR_ERROR0(_("Unable to get VIOS profile name."));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((slot = phypGetVIOSNextSlotNumber(conn)) == -1) {
|
|
|
|
VIR_ERROR0(_("Unable to get free slot number"));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Listing all the virtual_scsi_adapter interfaces, the new adapter must
|
|
|
|
* be appended to this list
|
|
|
|
* */
|
|
|
|
virBufferAddLit(&buf, "lssyscfg");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -r prof --filter lpar_ids=%d,profile_names=%s"
|
|
|
|
" -F virtual_scsi_adapters|sed -e s/\\\"//g",
|
|
|
|
vios_id, profile);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
/* Here I change the VIOS configuration to append the new adapter
|
|
|
|
* with the free slot I got with phypGetVIOSNextSlotNumber.
|
|
|
|
* */
|
|
|
|
virBufferAddLit(&buf, "chsyscfg");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -r prof -i 'name=%s,lpar_id=%d,"
|
|
|
|
"\"virtual_scsi_adapters=%s,%d/server/any/any/1\"'",
|
|
|
|
vios_name, vios_id, ret, slot);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
/* Finally I add the new scsi adapter to VIOS using the same slot
|
|
|
|
* I used in the VIOS configuration.
|
|
|
|
* */
|
|
|
|
virBufferAddLit(&buf, "chhwres -r virtualio --rsubtype scsi");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -p %s -o a -s %d -d 0 -a \"adapter_type=server\"",
|
|
|
|
vios_name, slot);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(profile);
|
|
|
|
VIR_FREE(vios_name);
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return result;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
phypGetVIOSFreeSCSIAdapter(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char *char_ptr;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lsmap -all -field svsa backing -fmt , ");
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
2010-06-24 22:25:56 +00:00
|
|
|
virBufferVSprintf(&buf, "|sed '/,[^.*]/d; s/,//g; q'");
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
if (exit_status < 0 || ret == NULL) {
|
|
|
|
VIR_FREE(ret);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-06-24 21:15:43 +00:00
|
|
|
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return ret;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypAttachDevice(virDomainPtr domain, const char *xml)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
virConnectPtr conn = domain->conn;
|
|
|
|
ConnectionData *connection_data = domain->conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = domain->conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *char_ptr = NULL;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *scsi_adapter = NULL;
|
|
|
|
int slot = 0;
|
|
|
|
char *vios_name = NULL;
|
|
|
|
char *profile = NULL;
|
|
|
|
virDomainDeviceDefPtr dev = NULL;
|
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
char *domain_name = NULL;
|
|
|
|
|
2011-04-09 09:59:10 +00:00
|
|
|
domain_name = escape_specialcharacters(domain->name);
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:10 +00:00
|
|
|
if (domain_name == NULL) {
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def->os.type = strdup("aix");
|
|
|
|
|
|
|
|
if (def->os.type == NULL) {
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dev = virDomainDeviceDefParse(phyp_driver->caps, def, xml,
|
|
|
|
VIR_DOMAIN_XML_INACTIVE);
|
|
|
|
if (!dev) {
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!
|
|
|
|
(vios_name =
|
|
|
|
phypGetLparNAME(session, managed_system, vios_id, conn))) {
|
|
|
|
VIR_ERROR0(_("Unable to get VIOS name"));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* First, let's look for a free SCSI Adapter
|
|
|
|
* */
|
|
|
|
if (!(scsi_adapter = phypGetVIOSFreeSCSIAdapter(conn))) {
|
|
|
|
/* If not found, let's create one.
|
|
|
|
* */
|
|
|
|
if (phypCreateServerSCSIAdapter(conn) == -1) {
|
|
|
|
VIR_ERROR0(_("Unable to create new virtual adapter"));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
} else {
|
|
|
|
if (!(scsi_adapter = phypGetVIOSFreeSCSIAdapter(conn))) {
|
|
|
|
VIR_ERROR0(_("Unable to create new virtual adapter"));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "mkvdev -vdev %s -vadapter %s",
|
|
|
|
dev->data.disk->src, scsi_adapter);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (!(profile = phypGetLparProfile(conn, domain->id))) {
|
|
|
|
VIR_ERROR0(_("Unable to get VIOS profile name."));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Let's get the slot number for the adapter we just created
|
|
|
|
* */
|
|
|
|
virBufferAddLit(&buf, "lshwres -r virtualio --rsubtype scsi");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" slot_num,backing_device|grep %s|cut -d, -f1",
|
|
|
|
dev->data.disk->src);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &slot) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
/* Listing all the virtual_scsi_adapter interfaces, the new adapter must
|
|
|
|
* be appended to this list
|
|
|
|
* */
|
|
|
|
virBufferAddLit(&buf, "lssyscfg");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r prof --filter lpar_ids=%d,profile_names=%s"
|
|
|
|
" -F virtual_scsi_adapters|sed -e 's/\"//g'",
|
|
|
|
vios_id, profile);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
/* Here I change the LPAR configuration to append the new adapter
|
|
|
|
* with the new slot we just created
|
|
|
|
* */
|
|
|
|
virBufferAddLit(&buf, "chsyscfg");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r prof -i 'name=%s,lpar_id=%d,"
|
|
|
|
"\"virtual_scsi_adapters=%s,%d/client/%d/%s/0\"'",
|
|
|
|
domain_name, domain->id, ret, slot,
|
|
|
|
vios_id, vios_name);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &slot) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
/* Finally I add the new scsi adapter to VIOS using the same slot
|
|
|
|
* I used in the VIOS configuration.
|
|
|
|
* */
|
|
|
|
virBufferAddLit(&buf, "chhwres -r virtualio --rsubtype scsi");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -p %s -o a -s %d -d 0 -a \"adapter_type=server\"",
|
|
|
|
domain_name, slot);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL) {
|
|
|
|
VIR_ERROR0(_
|
|
|
|
("Possibly you don't have IBM Tools installed in your LPAR."
|
|
|
|
"Contact your support to enable this feature."));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
virDomainDeviceDefFree(dev);
|
|
|
|
virDomainDefFree(def);
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(vios_name);
|
|
|
|
VIR_FREE(scsi_adapter);
|
2011-04-09 09:59:08 +00:00
|
|
|
VIR_FREE(profile);
|
|
|
|
VIR_FREE(domain_name);
|
|
|
|
|
|
|
|
return result;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
static char *
|
|
|
|
phypVolumeGetKey(virConnectPtr conn, const char *name)
|
2010-06-24 21:15:43 +00:00
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char *char_ptr;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lslv %s -field lvid", name);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "|sed -e 's/^LV IDENTIFIER://' -e 's/ //g'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:07 +00:00
|
|
|
return NULL;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
if (exit_status < 0 || ret == NULL) {
|
|
|
|
VIR_FREE(ret);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-06-24 21:15:43 +00:00
|
|
|
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
|
|
|
|
return ret;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
phypGetStoragePoolDevice(virConnectPtr conn, char *name)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char *char_ptr;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lssp -detail -sp %s -field name", name);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "|sed '1d; s/ //g'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
if (exit_status < 0 || ret == NULL) {
|
|
|
|
VIR_FREE(ret);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-06-24 21:15:43 +00:00
|
|
|
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return ret;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long int
|
|
|
|
phypGetStoragePoolSize(virConnectPtr conn, char *name)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
2011-04-09 09:59:08 +00:00
|
|
|
int sp_size = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
char *char_ptr;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lssp -detail -sp %s -field size", name);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "|sed '1d; s/ //g'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &sp_size) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return sp_size;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
static char *
|
2010-06-24 21:15:43 +00:00
|
|
|
phypBuildVolume(virConnectPtr conn, const char *lvname, const char *spname,
|
2011-04-09 09:59:07 +00:00
|
|
|
unsigned int capacity)
|
2010-06-24 21:15:43 +00:00
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2011-04-09 09:59:08 +00:00
|
|
|
char *key = NULL;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "mklv -lv %s %s %d", lvname, spname, capacity);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:07 +00:00
|
|
|
return NULL;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2010-06-24 21:15:43 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0) {
|
|
|
|
VIR_ERROR(_("Unable to create Volume: %s"), ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
key = phypVolumeGetKey(conn, lvname);
|
|
|
|
|
|
|
|
if (key == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return key;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
phypVolumeLookupByName(virStoragePoolPtr pool, const char *volname)
|
|
|
|
{
|
2011-04-09 09:59:07 +00:00
|
|
|
char *key;
|
|
|
|
virStorageVolPtr vol;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
key = phypVolumeGetKey(pool->conn, volname);
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
if (key == NULL)
|
2010-06-24 21:15:43 +00:00
|
|
|
return NULL;
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
vol = virGetStorageVol(pool->conn, pool->name, volname, key);
|
|
|
|
|
|
|
|
VIR_FREE(key);
|
|
|
|
|
|
|
|
return vol;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
phypStorageVolCreateXML(virStoragePoolPtr pool,
|
|
|
|
const char *xml, unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
virStorageVolDefPtr voldef = NULL;
|
|
|
|
virStoragePoolDefPtr spdef = NULL;
|
|
|
|
virStorageVolPtr vol = NULL;
|
|
|
|
char *key = NULL;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(spdef) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Filling spdef manually
|
|
|
|
* */
|
|
|
|
if (pool->name != NULL) {
|
|
|
|
spdef->name = pool->name;
|
|
|
|
} else {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pool's name."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (memcpy(spdef->uuid, pool->uuid, VIR_UUID_BUFLEN) == NULL) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pool's uuid."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((spdef->capacity =
|
|
|
|
phypGetStoragePoolSize(pool->conn, pool->name)) == -1) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pools's size."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Information not avaliable */
|
|
|
|
spdef->allocation = 0;
|
|
|
|
spdef->available = 0;
|
|
|
|
|
|
|
|
spdef->source.ndevice = 1;
|
|
|
|
|
|
|
|
/*XXX source adapter not working properly, should show hdiskX */
|
|
|
|
if ((spdef->source.adapter =
|
|
|
|
phypGetStoragePoolDevice(pool->conn, pool->name)) == NULL) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pools's source adapter."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((voldef = virStorageVolDefParseString(spdef, xml)) == NULL) {
|
|
|
|
VIR_ERROR0(_("Error parsing volume XML."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checking if this name already exists on this system */
|
|
|
|
if (phypVolumeLookupByName(pool, voldef->name) != NULL) {
|
|
|
|
VIR_ERROR0(_("StoragePool name already exists."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The key must be NULL, the Power Hypervisor creates a key
|
|
|
|
* in the moment you create the volume.
|
|
|
|
* */
|
|
|
|
if (voldef->key) {
|
|
|
|
VIR_ERROR0(_("Key must be empty, Power Hypervisor will create one for you."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (voldef->capacity) {
|
|
|
|
VIR_ERROR0(_("Capacity cannot be empty."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
key = phypBuildVolume(pool->conn, voldef->name, spdef->name,
|
|
|
|
voldef->capacity);
|
|
|
|
|
|
|
|
if (key == NULL)
|
2010-06-24 21:15:43 +00:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
if ((vol =
|
|
|
|
virGetStorageVol(pool->conn, pool->name, voldef->name,
|
|
|
|
key)) == NULL)
|
|
|
|
goto err;
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
VIR_FREE(key);
|
|
|
|
|
2010-06-24 21:15:43 +00:00
|
|
|
return vol;
|
|
|
|
|
|
|
|
err:
|
2011-04-09 09:59:07 +00:00
|
|
|
VIR_FREE(key);
|
2010-06-24 21:15:43 +00:00
|
|
|
virStorageVolDefFree(voldef);
|
|
|
|
virStoragePoolDefFree(spdef);
|
|
|
|
if (vol)
|
|
|
|
virUnrefStorageVol(vol);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
phypVolumeGetPhysicalVolumeByStoragePool(virStorageVolPtr vol, char *sp)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = vol->conn;
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char *char_ptr;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lssp -detail -sp %s -field pvname", sp);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "|sed 1d");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
if (exit_status < 0 || ret == NULL) {
|
|
|
|
VIR_FREE(ret);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-06-24 21:15:43 +00:00
|
|
|
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return ret;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
phypVolumeLookupByPath(virConnectPtr conn, const char *volname)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *spname = NULL;
|
2011-04-09 09:59:07 +00:00
|
|
|
char *char_ptr;
|
2010-06-24 21:15:43 +00:00
|
|
|
char *key = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2011-04-09 09:59:08 +00:00
|
|
|
virStorageVolPtr vol = NULL;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lslv %s -field vgname", volname);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "|sed -e 's/^VOLUME GROUP://g' -e 's/ //g'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
spname = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || spname == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
char_ptr = strchr(spname, '\n');
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
key = phypVolumeGetKey(conn, volname);
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
if (key == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
vol = virGetStorageVol(conn, spname, volname, key);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(spname);
|
2011-04-09 09:59:07 +00:00
|
|
|
VIR_FREE(key);
|
|
|
|
|
|
|
|
return vol;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypGetStoragePoolUUID(virConnectPtr conn, unsigned char *uuid,
|
|
|
|
const char *name)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lsdev -dev %s -attr vgserial_id", name);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "|sed '1,2d'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (memmove(uuid, ret, VIR_UUID_BUFLEN) == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return result;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
phypStoragePoolLookupByName(virConnectPtr conn, const char *name)
|
|
|
|
{
|
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
|
|
|
|
|
|
|
if (phypGetStoragePoolUUID(conn, uuid, name) == -1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return virGetStoragePool(conn, name, uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
phypVolumeGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
virStorageVolDef voldef;
|
|
|
|
virStoragePoolDef pool;
|
|
|
|
virStoragePoolPtr sp;
|
2011-04-09 09:59:07 +00:00
|
|
|
char *xml;
|
|
|
|
|
2010-06-24 21:15:43 +00:00
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
memset(&voldef, 0, sizeof(virStorageVolDef));
|
2011-04-09 09:59:08 +00:00
|
|
|
memset(&pool, 0, sizeof(virStoragePoolDef));
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
sp = phypStoragePoolLookupByName(vol->conn, vol->pool);
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (!sp)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (sp->name != NULL) {
|
|
|
|
pool.name = sp->name;
|
|
|
|
} else {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage sp's name."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (memmove(pool.uuid, sp->uuid, VIR_UUID_BUFLEN) == NULL) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage sp's uuid."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pool.capacity = phypGetStoragePoolSize(sp->conn, sp->name)) == -1) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage sps's size."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Information not avaliable */
|
|
|
|
pool.allocation = 0;
|
|
|
|
pool.available = 0;
|
|
|
|
|
|
|
|
pool.source.ndevice = 1;
|
|
|
|
|
|
|
|
if ((pool.source.adapter =
|
|
|
|
phypGetStoragePoolDevice(sp->conn, sp->name)) == NULL) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage sps's source adapter."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vol->name != NULL)
|
|
|
|
voldef.name = vol->name;
|
|
|
|
else {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pool's name."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
voldef.key = strdup(vol->key);
|
|
|
|
|
|
|
|
if (voldef.key == NULL) {
|
|
|
|
virReportOOMError();
|
2010-06-24 21:15:43 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
voldef.type = VIR_STORAGE_POOL_LOGICAL;
|
|
|
|
|
2011-04-09 09:59:07 +00:00
|
|
|
xml = virStorageVolDefFormat(&pool, &voldef);
|
|
|
|
|
|
|
|
VIR_FREE(voldef.key);
|
|
|
|
|
|
|
|
return xml;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
err:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The Volume Group path here will be treated as suggested in the
|
|
|
|
* email on the libvirt mailling list. As soon as I can't get the
|
|
|
|
* path for every volume, the path will be a representation in
|
|
|
|
* the form:
|
|
|
|
*
|
|
|
|
* /physical_volume/storage_pool/logical_volume
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
static char *
|
|
|
|
phypVolumeGetPath(virStorageVolPtr vol)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = vol->conn;
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *sp = NULL;
|
|
|
|
char *path = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char *char_ptr;
|
|
|
|
char *pv;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lslv %s -field vgname", vol->name);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
"|sed -e 's/^VOLUME GROUP://g' -e 's/ //g'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
sp = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || sp == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
char_ptr = strchr(sp, '\n');
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
|
|
|
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
pv = phypVolumeGetPhysicalVolumeByStoragePool(vol, sp);
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
if (!pv)
|
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
if (virAsprintf(&path, "/%s/%s/%s", pv, sp, vol->name) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(sp);
|
|
|
|
VIR_FREE(path);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return path;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypStoragePoolListVolumes(virStoragePoolPtr pool, char **const volumes,
|
|
|
|
int nvolumes)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
bool success = false;
|
2010-06-24 21:15:43 +00:00
|
|
|
virConnectPtr conn = pool->conn;
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
int got = 0;
|
|
|
|
int i;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *volumes_list = NULL;
|
|
|
|
char *char_ptr2 = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lsvg -lv %s -field lvname", pool->name);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "|sed '1,2d'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
/* I need to parse the textual return in order to get the volumes */
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
else {
|
|
|
|
volumes_list = ret;
|
|
|
|
|
|
|
|
while (got < nvolumes) {
|
|
|
|
char_ptr2 = strchr(volumes_list, '\n');
|
|
|
|
|
|
|
|
if (char_ptr2) {
|
|
|
|
*char_ptr2 = '\0';
|
|
|
|
if ((volumes[got++] = strdup(volumes_list)) == NULL) {
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
char_ptr2++;
|
|
|
|
volumes_list = char_ptr2;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
success = true;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (!success) {
|
|
|
|
for (i = 0; i < got; i++)
|
|
|
|
VIR_FREE(volumes[i]);
|
|
|
|
|
|
|
|
got = -1;
|
|
|
|
}
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return got;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypStoragePoolNumOfVolumes(virStoragePoolPtr pool)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = pool->conn;
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
2011-04-09 09:59:08 +00:00
|
|
|
int nvolumes = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
char *char_ptr;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
virBufferVSprintf(&buf, "lsvg -lv %s -field lvname", pool->name);
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
virBufferVSprintf(&buf, "|grep -c '^.*$'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &nvolumes) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
/* We need to remove 2 line from the header text output */
|
|
|
|
nvolumes -= 2;
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return nvolumes;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypDestroyStoragePool(virStoragePoolPtr pool)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
virConnectPtr conn = pool->conn;
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "rmsp %s", pool->name);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0) {
|
2011-04-14 16:35:42 +00:00
|
|
|
VIR_ERROR(_("Unable to destroy Storage Pool: %s"), ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return result;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypBuildStoragePool(virConnectPtr conn, virStoragePoolDefPtr def)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
virStoragePoolSource source = def->source;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "mksp -f %schild %s", def->name,
|
|
|
|
source.adapter);
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0) {
|
|
|
|
VIR_ERROR(_("Unable to create Storage Pool: %s"), ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return result;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypNumOfStoragePools(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
2011-04-09 09:59:08 +00:00
|
|
|
int nsp = -1;
|
2010-06-24 21:15:43 +00:00
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
char *char_ptr;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lsvg");
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "|grep -c '^.*$'");
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &nsp) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
2010-06-24 21:15:43 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return nsp;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypListStoragePools(virConnectPtr conn, char **const pools, int npools)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
bool success = false;
|
2010-06-24 21:15:43 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
int got = 0;
|
|
|
|
int i;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *storage_pools = NULL;
|
|
|
|
char *char_ptr2 = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
|
|
|
|
managed_system, vios_id);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf, "lsvg");
|
|
|
|
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferAddChar(&buf, '\'');
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
/* I need to parse the textual return in order to get the storage pools */
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
else {
|
|
|
|
storage_pools = ret;
|
|
|
|
|
|
|
|
while (got < npools) {
|
|
|
|
char_ptr2 = strchr(storage_pools, '\n');
|
|
|
|
|
|
|
|
if (char_ptr2) {
|
|
|
|
*char_ptr2 = '\0';
|
|
|
|
if ((pools[got++] = strdup(storage_pools)) == NULL) {
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
char_ptr2++;
|
|
|
|
storage_pools = char_ptr2;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
success = true;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (!success) {
|
|
|
|
for (i = 0; i < got; i++)
|
|
|
|
VIR_FREE(pools[i]);
|
|
|
|
|
|
|
|
got = -1;
|
|
|
|
}
|
2010-06-24 21:15:43 +00:00
|
|
|
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return got;
|
2010-06-24 21:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
phypGetStoragePoolLookUpByUUID(virConnectPtr conn,
|
|
|
|
const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr sp = NULL;
|
|
|
|
int npools = 0;
|
|
|
|
int gotpools = 0;
|
|
|
|
char **pools = NULL;
|
|
|
|
unsigned int i = 0;
|
|
|
|
unsigned char *local_uuid = NULL;
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(local_uuid, VIR_UUID_BUFLEN) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((npools = phypNumOfStoragePools(conn)) == -1) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(pools, npools) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((gotpools = phypListStoragePools(conn, pools, npools)) == -1) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gotpools != npools) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < gotpools; i++) {
|
|
|
|
if (phypGetStoragePoolUUID(conn, local_uuid, pools[i]) == -1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!memcmp(local_uuid, uuid, VIR_UUID_BUFLEN)) {
|
|
|
|
sp = virGetStoragePool(conn, pools[i], uuid);
|
|
|
|
VIR_FREE(local_uuid);
|
|
|
|
VIR_FREE(pools);
|
|
|
|
|
|
|
|
if (sp)
|
|
|
|
return sp;
|
|
|
|
else
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err:
|
|
|
|
VIR_FREE(local_uuid);
|
|
|
|
VIR_FREE(pools);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
phypStoragePoolCreateXML(virConnectPtr conn,
|
|
|
|
const char *xml, unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
virStoragePoolDefPtr def = NULL;
|
|
|
|
virStoragePoolPtr sp = NULL;
|
|
|
|
|
|
|
|
if (!(def = virStoragePoolDefParseString(xml)))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
/* checking if this name already exists on this system */
|
|
|
|
if (phypStoragePoolLookupByName(conn, def->name) != NULL) {
|
|
|
|
VIR_WARN0("StoragePool name already exists.");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checking if ID or UUID already exists on this system */
|
|
|
|
if (phypGetStoragePoolLookUpByUUID(conn, def->uuid) != NULL) {
|
|
|
|
VIR_WARN0("StoragePool uuid already exists.");
|
|
|
|
goto err;
|
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
2010-06-24 21:15:43 +00:00
|
|
|
if ((sp = virGetStoragePool(conn, def->name, def->uuid)) == NULL)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (phypBuildStoragePool(conn, def) == -1)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
return sp;
|
|
|
|
|
|
|
|
err:
|
|
|
|
virStoragePoolDefFree(def);
|
|
|
|
if (sp)
|
|
|
|
virUnrefStoragePool(sp);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
virStoragePoolDef def;
|
|
|
|
memset(&def, 0, sizeof(virStoragePoolDef));
|
|
|
|
|
|
|
|
if (pool->name != NULL)
|
|
|
|
def.name = pool->name;
|
|
|
|
else {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pool's name."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (memmove(def.uuid, pool->uuid, VIR_UUID_BUFLEN) == NULL) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pool's uuid."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((def.capacity =
|
|
|
|
phypGetStoragePoolSize(pool->conn, pool->name)) == -1) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pools's size."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Information not avaliable */
|
|
|
|
def.allocation = 0;
|
|
|
|
def.available = 0;
|
|
|
|
|
|
|
|
def.source.ndevice = 1;
|
|
|
|
|
|
|
|
/*XXX source adapter not working properly, should show hdiskX */
|
|
|
|
if ((def.source.adapter =
|
|
|
|
phypGetStoragePoolDevice(pool->conn, pool->name)) == NULL) {
|
|
|
|
VIR_ERROR0(_("Unable to determine storage pools's source adapter."));
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return virStoragePoolDefFormat(&def);
|
|
|
|
|
|
|
|
err:
|
|
|
|
return NULL;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
2011-03-28 20:07:20 +00:00
|
|
|
static int
|
|
|
|
phypInterfaceDestroy(virInterfacePtr iface,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
ConnectionData *connection_data = iface->conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = iface->conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
|
|
|
int slot_num = 0;
|
|
|
|
int lpar_id = 0;
|
|
|
|
char *char_ptr;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
2011-04-14 18:52:09 +00:00
|
|
|
int rv = -1;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/* Getting the remote slot number */
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype eth --level lpar "
|
|
|
|
" -F mac_addr,slot_num|"
|
|
|
|
" sed -n '/%s/ s/^.*,//p'", iface->mac);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, iface->conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &slot_num) == -1)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/* Getting the remote slot number */
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype eth --level lpar "
|
|
|
|
" -F mac_addr,lpar_id|"
|
|
|
|
" sed -n '/%s/ s/^.*,//p'", iface->mac);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, iface->conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &lpar_id) == -1)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/* excluding interface */
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "chhwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype eth"
|
|
|
|
" --id %d -o r -s %d", lpar_id, slot_num);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, iface->conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret != NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
rv = 0;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
cleanup:
|
2011-03-28 20:07:20 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-14 18:52:09 +00:00
|
|
|
return rv;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virInterfacePtr
|
|
|
|
phypInterfaceDefineXML(virConnectPtr conn, const char *xml,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *char_ptr;
|
|
|
|
char *cmd = NULL;
|
|
|
|
int slot = 0;
|
|
|
|
char *ret = NULL;
|
|
|
|
char name[PHYP_IFACENAME_SIZE];
|
|
|
|
char mac[PHYP_MAC_SIZE];
|
|
|
|
virInterfaceDefPtr def;
|
2011-04-14 18:52:09 +00:00
|
|
|
virInterfacePtr result = NULL;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
if (!(def = virInterfaceDefParseString(xml)))
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/* Now need to get the next free slot number */
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype slot --level slot"
|
|
|
|
" -Fslot_num --filter lpar_names=%s"
|
|
|
|
" |sort|tail -n 1", def->name);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &slot) == -1)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/* The next free slot itself: */
|
|
|
|
slot++;
|
|
|
|
|
|
|
|
/* Now adding the new network interface */
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "chhwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype eth"
|
|
|
|
" -p %s -o a -s %d -a port_vlan_id=1,"
|
|
|
|
"ieee_virtual_eth=0", def->name, slot);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret != NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/* Need to sleep a little while to wait for the HMC to
|
|
|
|
* complete the execution of the command.
|
|
|
|
* */
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
/* Getting the new interface name */
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype slot --level slot"
|
|
|
|
" |sed '/lpar_name=%s/!d; /slot_num=%d/!d; "
|
|
|
|
"s/^.*drc_name=//'", def->name, slot);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL) {
|
|
|
|
/* roll back and excluding interface if error*/
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "chhwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype eth"
|
|
|
|
" -p %s -o r -s %d", def->name, slot);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(name, ret, PHYP_IFACENAME_SIZE-1);
|
|
|
|
|
|
|
|
/* Getting the new interface mac addr */
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
"-r virtualio --rsubtype eth --level lpar "
|
|
|
|
" |sed '/lpar_name=%s/!d; /slot_num=%d/!d; "
|
|
|
|
"s/^.*mac_addr=//'", def->name, slot);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
memcpy(mac, ret, PHYP_MAC_SIZE-1);
|
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
result = virGetInterface(conn, name, mac);
|
2011-03-28 20:07:20 +00:00
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
cleanup:
|
2011-03-28 20:07:20 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
virInterfaceDefFree(def);
|
2011-04-14 18:52:09 +00:00
|
|
|
return result;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virInterfacePtr
|
|
|
|
phypInterfaceLookupByName(virConnectPtr conn, const char *name)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *char_ptr;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int slot = 0;
|
|
|
|
int lpar_id = 0;
|
|
|
|
char mac[PHYP_MAC_SIZE];
|
2011-04-13 18:10:52 +00:00
|
|
|
virInterfacePtr result = NULL;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/*Getting the slot number for the interface */
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype slot --level slot "
|
|
|
|
" -F drc_name,slot_num |"
|
|
|
|
" sed -n '/%s/ s/^.*,//p'", name);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &slot) == -1)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/*Getting the lpar_id for the interface */
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype slot --level slot "
|
|
|
|
" -F drc_name,lpar_id |"
|
|
|
|
" sed -n '/%s/ s/^.*,//p'", name);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &lpar_id) == -1)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
/*Getting the interface mac */
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype eth --level lpar "
|
|
|
|
" -F lpar_id,slot_num,mac_addr|"
|
|
|
|
" sed -n '/%d,%d/ s/^.*,//p'", lpar_id, slot);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
memcpy(mac, ret, PHYP_MAC_SIZE-1);
|
|
|
|
|
2011-04-13 18:10:52 +00:00
|
|
|
result = virGetInterface(conn, name, ret);
|
2011-03-28 20:07:20 +00:00
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
cleanup:
|
2011-03-28 20:07:20 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypInterfaceIsActive(virInterfacePtr iface)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = iface->conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = iface->conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int exit_status = 0;
|
2011-04-14 18:52:09 +00:00
|
|
|
int state = -1;
|
2011-03-28 20:07:20 +00:00
|
|
|
char *char_ptr;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
" -r virtualio --rsubtype eth --level lpar "
|
|
|
|
" -F mac_addr,state |"
|
|
|
|
" sed -n '/%s/ s/^.*,//p'", iface->mac);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, iface->conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &state) == -1)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
cleanup:
|
2011-03-28 20:07:20 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypListInterfaces(virConnectPtr conn, char **const names, int nnames)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
|
|
|
int got = 0;
|
|
|
|
int i;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *networks = NULL;
|
|
|
|
char *char_ptr2 = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2011-04-14 18:52:09 +00:00
|
|
|
bool success = false;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -r virtualio --rsubtype slot --level slot|"
|
|
|
|
" sed '/eth/!d; /lpar_id=%d/d; s/^.*drc_name=//g'",
|
|
|
|
vios_id);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
/* I need to parse the textual return in order to get the network
|
|
|
|
* interfaces */
|
2011-03-28 20:07:20 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
networks = ret;
|
|
|
|
|
|
|
|
while (got < nnames) {
|
|
|
|
char_ptr2 = strchr(networks, '\n');
|
|
|
|
|
|
|
|
if (char_ptr2) {
|
|
|
|
*char_ptr2 = '\0';
|
|
|
|
if ((names[got++] = strdup(networks)) == NULL) {
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
char_ptr2++;
|
|
|
|
networks = char_ptr2;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
cleanup:
|
|
|
|
if (!success) {
|
|
|
|
for (i = 0; i < got; i++)
|
|
|
|
VIR_FREE(names[i]);
|
|
|
|
}
|
2011-03-28 20:07:20 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
return got;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypNumOfInterfaces(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int exit_status = 0;
|
2011-04-14 18:52:09 +00:00
|
|
|
int nnets = -1;
|
2011-03-28 20:07:20 +00:00
|
|
|
char *char_ptr;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "lshwres ");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, "-m %s ", managed_system);
|
|
|
|
|
|
|
|
virBufferVSprintf(&buf,
|
|
|
|
"-r virtualio --rsubtype eth --level lpar|"
|
|
|
|
"grep -v lpar_id=%d|grep -c lpar_name", vios_id);
|
|
|
|
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
|
|
|
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
|
|
|
if (virStrToLong_i(ret, &char_ptr, 10, &nnets) == -1)
|
2011-04-14 18:52:09 +00:00
|
|
|
goto cleanup;
|
2011-03-28 20:07:20 +00:00
|
|
|
|
2011-04-14 18:52:09 +00:00
|
|
|
cleanup:
|
2011-03-28 20:07:20 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
return nnets;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypGetLparState(virConnectPtr conn, unsigned int lpar_id)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
2009-11-05 16:18:07 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *char_ptr = NULL;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int state = VIR_DOMAIN_NOSTATE;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lssyscfg -r lpar");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -F state --filter lpar_ids=%d", lpar_id);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return state;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (STREQ(ret, "Running"))
|
|
|
|
state = VIR_DOMAIN_RUNNING;
|
|
|
|
else if (STREQ(ret, "Not Activated"))
|
|
|
|
state = VIR_DOMAIN_SHUTOFF;
|
|
|
|
else if (STREQ(ret, "Shutting Down"))
|
|
|
|
state = VIR_DOMAIN_SHUTDOWN;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cleanup:
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
return state;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* XXX - is this needed? */
|
|
|
|
static int phypDiskType(virConnectPtr, char *) ATTRIBUTE_UNUSED;
|
|
|
|
static int
|
|
|
|
phypDiskType(virConnectPtr conn, char *backing_device)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *char_ptr;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int vios_id = phyp_driver->vios_id;
|
|
|
|
int disk_type = -1;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "viosvrcmd");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -p %d -c \"lssp -field name type "
|
2010-06-24 22:25:56 +00:00
|
|
|
"-fmt , -all|sed -n '/%s/ {\n s/^.*,//\n p\n}'\"",
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
vios_id, backing_device);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return disk_type;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0 || ret == NULL)
|
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char_ptr = strchr(ret, '\n');
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (char_ptr)
|
|
|
|
*char_ptr = '\0';
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (STREQ(ret, "LVPOOL"))
|
|
|
|
disk_type = VIR_DOMAIN_DISK_TYPE_BLOCK;
|
|
|
|
else if (STREQ(ret, "FBPOOL"))
|
|
|
|
disk_type = VIR_DOMAIN_DISK_TYPE_FILE;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cleanup:
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
return disk_type;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypNumDefinedDomains(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
return phypNumDomainsGeneric(conn, 1);
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypNumDomains(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
return phypNumDomainsGeneric(conn, 0);
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypListDomains(virConnectPtr conn, int *ids, int nids)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return phypListDomainsGeneric(conn, ids, nids, 0);
|
|
|
|
}
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
bool success = false;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int exit_status = 0;
|
|
|
|
int got = 0;
|
|
|
|
int i;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char *domains = NULL;
|
|
|
|
char *char_ptr2 = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "lssyscfg -r lpar");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
2010-06-24 22:25:56 +00:00
|
|
|
virBufferVSprintf(&buf, " -F name,state"
|
|
|
|
"|sed -n '/Not Activated/ {\n s/,.*$//\n p\n}'");
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return -1;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
/* I need to parse the textual return in order to get the domains */
|
|
|
|
if (exit_status < 0 || ret == NULL)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
else {
|
|
|
|
domains = ret;
|
2009-11-06 01:15:19 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
while (got < nnames) {
|
|
|
|
char_ptr2 = strchr(domains, '\n');
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (char_ptr2) {
|
|
|
|
*char_ptr2 = '\0';
|
|
|
|
if ((names[got++] = strdup(domains)) == NULL) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char_ptr2++;
|
|
|
|
domains = char_ptr2;
|
|
|
|
} else
|
|
|
|
break;
|
2009-11-08 21:08:54 +00:00
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
success = true;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (!success) {
|
|
|
|
for (i = 0; i < got; i++)
|
|
|
|
VIR_FREE(names[i]);
|
|
|
|
|
|
|
|
got = -1;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return got;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static virDomainPtr
|
|
|
|
phypDomainLookupByName(virConnectPtr conn, const char *lpar_name)
|
2009-11-05 23:19:16 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
int lpar_id = 0;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
unsigned char lpar_uuid[VIR_UUID_BUFLEN];
|
2009-11-05 23:19:16 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
lpar_id = phypGetLparID(session, managed_system, lpar_name, conn);
|
|
|
|
if (lpar_id == -1)
|
|
|
|
return NULL;
|
2009-11-05 23:19:16 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypGetLparUUID(lpar_uuid, lpar_id, conn) == -1)
|
|
|
|
return NULL;
|
2009-11-05 23:19:16 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
dom = virGetDomain(conn, lpar_name, lpar_uuid);
|
|
|
|
|
|
|
|
if (dom)
|
|
|
|
dom->id = lpar_id;
|
|
|
|
|
|
|
|
return dom;
|
2009-11-05 23:19:16 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static virDomainPtr
|
|
|
|
phypDomainLookupByID(virConnectPtr conn, int lpar_id)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
2009-11-05 16:18:07 +00:00
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int exit_status = 0;
|
|
|
|
unsigned char lpar_uuid[VIR_UUID_BUFLEN];
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
char *lpar_name = phypGetLparNAME(session, managed_system, lpar_id,
|
|
|
|
conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypGetLparUUID(lpar_uuid, lpar_id, conn) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
dom = virGetDomain(conn, lpar_name, lpar_uuid);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (dom)
|
|
|
|
dom->id = lpar_id;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(lpar_name);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return dom;
|
2009-11-05 16:18:07 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static char *
|
|
|
|
phypDomainDumpXML(virDomainPtr dom, int flags)
|
2009-11-05 16:18:07 +00:00
|
|
|
{
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = dom->conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
2009-11-05 16:18:07 +00:00
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virDomainDef def;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
memset(&def, 0, sizeof(virDomainDef));
|
2010-06-16 20:33:27 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
def.virtType = VIR_DOMAIN_VIRT_PHYP;
|
|
|
|
def.id = dom->id;
|
|
|
|
|
|
|
|
char *lpar_name = phypGetLparNAME(session, managed_system, def.id,
|
|
|
|
dom->conn);
|
|
|
|
|
|
|
|
if (lpar_name == NULL) {
|
|
|
|
VIR_ERROR0(_("Unable to determine domain's name."));
|
|
|
|
goto err;
|
2010-06-16 20:33:27 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypGetLparUUID(def.uuid, dom->id, dom->conn) == -1) {
|
|
|
|
VIR_ERROR0(_("Unable to generate random uuid."));
|
2010-06-16 20:33:27 +00:00
|
|
|
goto err;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2010-10-12 14:43:39 +00:00
|
|
|
if ((def.mem.max_balloon =
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypGetLparMem(dom->conn, managed_system, dom->id, 0)) == 0) {
|
|
|
|
VIR_ERROR0(_("Unable to determine domain's max memory."));
|
|
|
|
goto err;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2010-10-12 14:43:39 +00:00
|
|
|
if ((def.mem.cur_balloon =
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0) {
|
|
|
|
VIR_ERROR0(_("Unable to determine domain's memory."));
|
|
|
|
goto err;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2010-09-29 16:20:07 +00:00
|
|
|
if ((def.maxvcpus = def.vcpus =
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypGetLparCPU(dom->conn, managed_system, dom->id)) == 0) {
|
|
|
|
VIR_ERROR0(_("Unable to determine domain's CPU."));
|
2009-11-05 16:18:07 +00:00
|
|
|
goto err;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
return virDomainDefFormat(&def, flags);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
err:
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypDomainResume(virDomainPtr dom)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = dom->conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "chsysstate");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -r lpar -o on --id %d -f %s",
|
|
|
|
dom->id, dom->name);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, dom->conn);
|
2009-11-05 16:18:07 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
2009-11-05 16:18:07 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return result;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypDomainShutdown(virDomainPtr dom)
|
2009-07-24 14:17:06 +00:00
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = dom->conn->networkPrivateData;
|
|
|
|
virConnectPtr conn = dom->conn;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "chsysstate");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -r lpar -o shutdown --id %d", dom->id);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2011-04-09 09:59:08 +00:00
|
|
|
return -1;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-07-24 14:17:06 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, dom->conn);
|
|
|
|
|
|
|
|
if (exit_status < 0)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return result;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|
|
|
{
|
|
|
|
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
|
|
|
|
info->state = phypGetLparState(dom->conn, dom->id);
|
|
|
|
|
|
|
|
if ((info->maxMem =
|
|
|
|
phypGetLparMem(dom->conn, managed_system, dom->id, 0)) == 0)
|
|
|
|
VIR_WARN0("Unable to determine domain's max memory.");
|
|
|
|
|
|
|
|
if ((info->memory =
|
|
|
|
phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0)
|
|
|
|
VIR_WARN0("Unable to determine domain's memory.");
|
|
|
|
|
|
|
|
if ((info->nrVirtCpu =
|
|
|
|
phypGetLparCPU(dom->conn, managed_system, dom->id)) == 0)
|
|
|
|
VIR_WARN0("Unable to determine domain's CPU.");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
phypDomainDestroy(virDomainPtr dom)
|
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = dom->conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "rmsyscfg");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -r lpar --id %d", dom->id);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
2009-07-24 14:17:06 +00:00
|
|
|
return -1;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, dom->conn);
|
|
|
|
|
|
|
|
if (exit_status < 0)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
if (phypUUIDTable_RemLpar(dom->conn, dom->id) == -1)
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2009-07-24 14:17:06 +00:00
|
|
|
|
2010-07-30 17:50:12 +00:00
|
|
|
dom->id = -1;
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
2010-07-30 17:50:12 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
return result;
|
2009-07-24 14:17:06 +00:00
|
|
|
}
|
2009-09-04 10:08:47 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static int
|
|
|
|
phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
|
2009-09-04 10:08:47 +00:00
|
|
|
{
|
2011-04-09 09:59:08 +00:00
|
|
|
int result = -1;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
int exit_status = 0;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
2009-09-04 10:08:47 +00:00
|
|
|
|
2010-10-12 14:43:39 +00:00
|
|
|
if (!def->mem.cur_balloon) {
|
2010-09-29 14:52:15 +00:00
|
|
|
PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
|
|
|
|
_("Field \"<memory>\" on the domain XML file is missing or has "
|
|
|
|
"invalid value."));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-09-29 14:52:15 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 14:43:39 +00:00
|
|
|
if (!def->mem.max_balloon) {
|
2010-09-29 14:52:15 +00:00
|
|
|
PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
|
|
|
|
_("Field \"<currentMemory>\" on the domain XML file is missing or"
|
|
|
|
" has invalid value."));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-09-29 14:52:15 +00:00
|
|
|
}
|
|
|
|
|
2010-09-30 19:13:29 +00:00
|
|
|
if (def->ndisks < 1) {
|
|
|
|
PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("Domain XML must contain at least one \"<disk>\" element."));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-09-30 19:13:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!def->disks[0]->src) {
|
|
|
|
PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
|
|
|
|
_("Field \"<src>\" under \"<disk>\" on the domain XML file is "
|
|
|
|
"missing."));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
2010-09-29 14:52:15 +00:00
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
virBufferAddLit(&buf, "mksyscfg");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " -r lpar -p %s -i min_mem=%d,desired_mem=%d,"
|
|
|
|
"max_mem=%d,desired_procs=%d,virtual_scsi_adapters=%s",
|
2010-10-12 14:43:39 +00:00
|
|
|
def->name, (int) def->mem.cur_balloon,
|
|
|
|
(int) def->mem.cur_balloon, (int) def->mem.max_balloon,
|
|
|
|
(int) def->vcpus, def->disks[0]->src);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
2009-09-04 10:08:47 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
ret = phypExec(session, cmd, &exit_status, conn);
|
2009-09-04 10:08:47 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (exit_status < 0) {
|
|
|
|
VIR_ERROR(_("Unable to create LPAR. Reason: '%s'"), ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-09-04 10:08:47 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if (phypUUIDTable_AddLpar(conn, def->uuid, def->id) == -1) {
|
|
|
|
VIR_ERROR0(_("Unable to add LPAR to the table"));
|
2011-04-09 09:59:08 +00:00
|
|
|
goto cleanup;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-09-04 10:08:47 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
result = 0;
|
2009-09-04 10:08:47 +00:00
|
|
|
|
2011-04-09 09:59:08 +00:00
|
|
|
cleanup:
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
2011-04-09 09:59:08 +00:00
|
|
|
|
|
|
|
return result;
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
}
|
2009-09-04 10:08:47 +00:00
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static virDomainPtr
|
|
|
|
phypDomainCreateAndStart(virConnectPtr conn,
|
|
|
|
const char *xml, unsigned int flags)
|
|
|
|
{
|
2011-03-28 20:07:20 +00:00
|
|
|
virCheckFlags(0, NULL);
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
|
|
|
|
ConnectionData *connection_data = conn->networkPrivateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
uuid_tablePtr uuid_table = phyp_driver->uuid_table;
|
|
|
|
lparPtr *lpars = uuid_table->lpars;
|
|
|
|
unsigned int i = 0;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
if (!(def = virDomainDefParseString(phyp_driver->caps, xml,
|
|
|
|
VIR_DOMAIN_XML_SECURE)))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
/* checking if this name already exists on this system */
|
2010-08-17 19:04:49 +00:00
|
|
|
if (phypGetLparID(session, managed_system, def->name, conn) != -1) {
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
VIR_WARN0("LPAR name already exists.");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checking if ID or UUID already exists on this system */
|
|
|
|
for (i = 0; i < uuid_table->nlpars; i++) {
|
|
|
|
if (lpars[i]->id == def->id || lpars[i]->uuid == def->uuid) {
|
|
|
|
VIR_WARN0("LPAR ID or UUID already exists.");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((dom = virGetDomain(conn, def->name, def->uuid)) == NULL)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (phypBuildLpar(conn, def) == -1)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (phypDomainResume(dom) == -1)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
return dom;
|
|
|
|
|
|
|
|
err:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
if (dom)
|
|
|
|
virUnrefDomain(dom);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
phypConnectGetCapabilities(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
phyp_driverPtr phyp_driver = conn->privateData;
|
|
|
|
char *xml;
|
|
|
|
|
|
|
|
if ((xml = virCapabilitiesFormatXML(phyp_driver->caps)) == NULL)
|
|
|
|
virReportOOMError();
|
|
|
|
|
|
|
|
return xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
phypDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|
|
|
unsigned int flags)
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
{
|
|
|
|
ConnectionData *connection_data = dom->conn->networkPrivateData;
|
|
|
|
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
|
|
|
LIBSSH2_SESSION *session = connection_data->session;
|
|
|
|
int system_type = phyp_driver->system_type;
|
|
|
|
char *managed_system = phyp_driver->managed_system;
|
|
|
|
int exit_status = 0;
|
|
|
|
char *cmd = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
char operation;
|
|
|
|
unsigned long ncpus = 0;
|
|
|
|
unsigned int amount = 0;
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
|
|
|
PHYP_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
if ((ncpus = phypGetLparCPU(dom->conn, managed_system, dom->id)) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (nvcpus > phypGetLparCPUMAX(dom)) {
|
|
|
|
VIR_ERROR0(_("You are trying to set a number of CPUs bigger than "
|
|
|
|
"the max possible."));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ncpus > nvcpus) {
|
|
|
|
operation = 'r';
|
|
|
|
amount = nvcpus - ncpus;
|
|
|
|
} else if (ncpus < nvcpus) {
|
|
|
|
operation = 'a';
|
|
|
|
amount = nvcpus - ncpus;
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
virBufferAddLit(&buf, "chhwres -r proc");
|
|
|
|
if (system_type == HMC)
|
|
|
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
|
|
|
virBufferVSprintf(&buf, " --id %d -o %c --procunits %d 2>&1 |sed "
|
|
|
|
"-e 's/^.*\\([0-9][0-9]*.[0-9][0-9]*\\).*$/\\1/'",
|
|
|
|
dom->id, operation, amount);
|
|
|
|
if (virBufferError(&buf)) {
|
|
|
|
virBufferFreeAndReset(&buf);
|
|
|
|
virReportOOMError();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
cmd = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
ret = phypExec(session, cmd, &exit_status, dom->conn);
|
|
|
|
|
|
|
|
if (exit_status < 0) {
|
|
|
|
VIR_ERROR0(_
|
|
|
|
("Possibly you don't have IBM Tools installed in your LPAR."
|
|
|
|
" Contact your support to enable this feature."));
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_FREE(cmd);
|
|
|
|
VIR_FREE(ret);
|
|
|
|
return 0;
|
2009-09-04 10:08:47 +00:00
|
|
|
|
|
|
|
}
|
2009-11-05 16:18:07 +00:00
|
|
|
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
static int
|
|
|
|
phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
|
|
|
|
{
|
|
|
|
return phypDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
|
|
|
|
}
|
|
|
|
|
2010-06-24 21:39:27 +00:00
|
|
|
static virDrvOpenStatus
|
2010-08-12 14:33:12 +00:00
|
|
|
phypVIOSDriverOpen(virConnectPtr conn,
|
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
2010-11-12 12:58:16 +00:00
|
|
|
int flags ATTRIBUTE_UNUSED)
|
2010-06-24 21:39:27 +00:00
|
|
|
{
|
2010-06-28 17:33:05 +00:00
|
|
|
if (conn->driver->no != VIR_DRV_PHYP)
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
2010-06-24 21:39:27 +00:00
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-08-12 14:33:12 +00:00
|
|
|
phypVIOSDriverClose(virConnectPtr conn ATTRIBUTE_UNUSED)
|
2010-06-24 21:39:27 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
static virDriver phypDriver = {
|
|
|
|
VIR_DRV_PHYP, "PHYP", phypOpen, /* open */
|
|
|
|
phypClose, /* close */
|
|
|
|
NULL, /* supports_feature */
|
|
|
|
NULL, /* type */
|
|
|
|
NULL, /* version */
|
|
|
|
NULL, /* libvirtVersion (impl. in libvirt.c) */
|
|
|
|
NULL, /* getHostname */
|
2011-02-07 21:14:56 +00:00
|
|
|
NULL, /* getSysinfo */
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
NULL, /* getMaxVcpus */
|
|
|
|
NULL, /* nodeGetInfo */
|
|
|
|
phypConnectGetCapabilities, /* getCapabilities */
|
|
|
|
phypListDomains, /* listDomains */
|
|
|
|
phypNumDomains, /* numOfDomains */
|
|
|
|
phypDomainCreateAndStart, /* domainCreateXML */
|
|
|
|
phypDomainLookupByID, /* domainLookupByID */
|
|
|
|
NULL, /* domainLookupByUUID */
|
|
|
|
phypDomainLookupByName, /* domainLookupByName */
|
|
|
|
NULL, /* domainSuspend */
|
|
|
|
phypDomainResume, /* domainResume */
|
|
|
|
phypDomainShutdown, /* domainShutdown */
|
|
|
|
NULL, /* domainReboot */
|
|
|
|
phypDomainDestroy, /* domainDestroy */
|
|
|
|
NULL, /* domainGetOSType */
|
|
|
|
NULL, /* domainGetMaxMemory */
|
|
|
|
NULL, /* domainSetMaxMemory */
|
|
|
|
NULL, /* domainSetMemory */
|
2011-03-02 08:07:48 +00:00
|
|
|
NULL, /* domainSetMemoryFlags */
|
2011-02-22 05:31:57 +00:00
|
|
|
NULL, /* domainSetMemoryParameters */
|
|
|
|
NULL, /* domainGetMemoryParameters */
|
|
|
|
NULL, /* domainSetBlkioParameters */
|
|
|
|
NULL, /* domainGetBlkioParameters */
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
phypDomainGetInfo, /* domainGetInfo */
|
|
|
|
NULL, /* domainSave */
|
|
|
|
NULL, /* domainRestore */
|
|
|
|
NULL, /* domainCoreDump */
|
|
|
|
phypDomainSetCPU, /* domainSetVcpus */
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
phypDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
|
|
|
phypDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
NULL, /* domainPinVcpu */
|
|
|
|
NULL, /* domainGetVcpus */
|
|
|
|
phypGetLparCPUMAX, /* domainGetMaxVcpus */
|
|
|
|
NULL, /* domainGetSecurityLabel */
|
|
|
|
NULL, /* nodeGetSecurityModel */
|
|
|
|
phypDomainDumpXML, /* domainDumpXML */
|
|
|
|
NULL, /* domainXMLFromNative */
|
|
|
|
NULL, /* domainXMLToNative */
|
|
|
|
phypListDefinedDomains, /* listDefinedDomains */
|
|
|
|
phypNumDefinedDomains, /* numOfDefinedDomains */
|
|
|
|
NULL, /* domainCreate */
|
|
|
|
NULL, /* domainCreateWithFlags */
|
|
|
|
NULL, /* domainDefineXML */
|
|
|
|
NULL, /* domainUndefine */
|
2010-06-24 21:15:43 +00:00
|
|
|
phypAttachDevice, /* domainAttachDevice */
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
NULL, /* domainAttachDeviceFlags */
|
|
|
|
NULL, /* domainDetachDevice */
|
|
|
|
NULL, /* domainDetachDeviceFlags */
|
|
|
|
NULL, /* domainUpdateDeviceFlags */
|
|
|
|
NULL, /* domainGetAutostart */
|
|
|
|
NULL, /* domainSetAutostart */
|
|
|
|
NULL, /* domainGetSchedulerType */
|
|
|
|
NULL, /* domainGetSchedulerParameters */
|
|
|
|
NULL, /* domainSetSchedulerParameters */
|
|
|
|
NULL, /* domainMigratePrepare */
|
|
|
|
NULL, /* domainMigratePerform */
|
|
|
|
NULL, /* domainMigrateFinish */
|
|
|
|
NULL, /* domainBlockStats */
|
|
|
|
NULL, /* domainInterfaceStats */
|
|
|
|
NULL, /* domainMemoryStats */
|
|
|
|
NULL, /* domainBlockPeek */
|
|
|
|
NULL, /* domainMemoryPeek */
|
|
|
|
NULL, /* domainGetBlockInfo */
|
|
|
|
NULL, /* nodeGetCellsFreeMemory */
|
|
|
|
NULL, /* getFreeMemory */
|
|
|
|
NULL, /* domainEventRegister */
|
|
|
|
NULL, /* domainEventDeregister */
|
|
|
|
NULL, /* domainMigratePrepare2 */
|
|
|
|
NULL, /* domainMigrateFinish2 */
|
|
|
|
NULL, /* nodeDeviceDettach */
|
|
|
|
NULL, /* nodeDeviceReAttach */
|
|
|
|
NULL, /* nodeDeviceReset */
|
|
|
|
NULL, /* domainMigratePrepareTunnel */
|
|
|
|
phypIsEncrypted, /* isEncrypted */
|
|
|
|
phypIsSecure, /* isSecure */
|
|
|
|
NULL, /* domainIsActive */
|
|
|
|
NULL, /* domainIsPersistent */
|
2010-11-24 07:43:15 +00:00
|
|
|
phypIsUpdated, /* domainIsUpdated */
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
NULL, /* cpuCompare */
|
|
|
|
NULL, /* cpuBaseline */
|
|
|
|
NULL, /* domainGetJobInfo */
|
|
|
|
NULL, /* domainAbortJob */
|
|
|
|
NULL, /* domainMigrateSetMaxDowntime */
|
Add public API for setting migration speed on the fly
It is possible to set a migration speed limit when starting
migration. This new API allows the speed limit to be changed
on the fly to adjust to changing conditions
* src/driver.h, src/libvirt.c, src/libvirt_public.syms,
include/libvirt/libvirt.h.in: Add virDomainMigrateSetMaxSpeed
* src/esx/esx_driver.c, src/lxc/lxc_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_driver.c,
src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
src/remote/remote_driver.c, src/test/test_driver.c,
src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/vmware/vmware_driver.c, src/xen/xen_driver.c,
src/libxl/libxl_driver.c: Stub new API
2011-02-17 13:57:53 +00:00
|
|
|
NULL, /* domainMigrateSetMaxSpeed */
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
NULL, /* domainEventRegisterAny */
|
|
|
|
NULL, /* domainEventDeregisterAny */
|
|
|
|
NULL, /* domainManagedSave */
|
|
|
|
NULL, /* domainHasManagedSaveImage */
|
|
|
|
NULL, /* domainManagedSaveRemove */
|
|
|
|
NULL, /* domainSnapshotCreateXML */
|
|
|
|
NULL, /* domainSnapshotDumpXML */
|
|
|
|
NULL, /* domainSnapshotNum */
|
|
|
|
NULL, /* domainSnapshotListNames */
|
|
|
|
NULL, /* domainSnapshotLookupByName */
|
|
|
|
NULL, /* domainHasCurrentSnapshot */
|
|
|
|
NULL, /* domainSnapshotCurrent */
|
|
|
|
NULL, /* domainRevertToSnapshot */
|
|
|
|
NULL, /* domainSnapshotDelete */
|
2010-04-13 18:02:46 +00:00
|
|
|
NULL, /* qemuMonitorCommand */
|
Introduce a virDomainOpenConsole API
To enable virsh console (or equivalent) to be used remotely
it is necessary to provide remote access to the /dev/pts/XXX
pseudo-TTY associated with the console/serial/parallel device
in the guest. The virStream API provide a bi-directional I/O
stream capability that can be used for this purpose. This
patch thus introduces a virDomainOpenConsole API that uses
the stream APIs.
* src/libvirt.c, src/libvirt_public.syms,
include/libvirt/libvirt.h.in, src/driver.h: Define the
new virDomainOpenConsole API
* src/esx/esx_driver.c, src/lxc/lxc_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_driver.c,
src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
src/remote/remote_driver.c, src/test/test_driver.c,
src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Stub
API entry point
2010-07-23 12:34:31 +00:00
|
|
|
NULL, /* domainOpenConsole */
|
phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them. Rather than do lots of forward declarations, I was able
to topologically sort the file. So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.
* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-24 21:05:16 +00:00
|
|
|
};
|
|
|
|
|
2010-06-24 21:39:27 +00:00
|
|
|
static virStorageDriver phypStorageDriver = {
|
|
|
|
.name = "PHYP",
|
2010-08-12 14:33:12 +00:00
|
|
|
.open = phypVIOSDriverOpen,
|
|
|
|
.close = phypVIOSDriverClose,
|
2010-06-24 21:39:27 +00:00
|
|
|
|
2010-06-24 21:15:43 +00:00
|
|
|
.numOfPools = phypNumOfStoragePools,
|
|
|
|
.listPools = phypListStoragePools,
|
2010-06-24 21:39:27 +00:00
|
|
|
.numOfDefinedPools = NULL,
|
|
|
|
.listDefinedPools = NULL,
|
|
|
|
.findPoolSources = NULL,
|
2010-06-24 21:15:43 +00:00
|
|
|
.poolLookupByName = phypStoragePoolLookupByName,
|
|
|
|
.poolLookupByUUID = phypGetStoragePoolLookUpByUUID,
|
2010-06-24 21:39:27 +00:00
|
|
|
.poolLookupByVolume = NULL,
|
2010-06-24 21:15:43 +00:00
|
|
|
.poolCreateXML = phypStoragePoolCreateXML,
|
2010-06-24 21:39:27 +00:00
|
|
|
.poolDefineXML = NULL,
|
|
|
|
.poolBuild = NULL,
|
|
|
|
.poolUndefine = NULL,
|
|
|
|
.poolCreate = NULL,
|
2010-06-24 21:15:43 +00:00
|
|
|
.poolDestroy = phypDestroyStoragePool,
|
2010-06-24 21:39:27 +00:00
|
|
|
.poolDelete = NULL,
|
|
|
|
.poolRefresh = NULL,
|
|
|
|
.poolGetInfo = NULL,
|
2010-06-24 21:15:43 +00:00
|
|
|
.poolGetXMLDesc = phypGetStoragePoolXMLDesc,
|
2010-06-24 21:39:27 +00:00
|
|
|
.poolGetAutostart = NULL,
|
|
|
|
.poolSetAutostart = NULL,
|
2010-06-24 21:15:43 +00:00
|
|
|
.poolNumOfVolumes = phypStoragePoolNumOfVolumes,
|
|
|
|
.poolListVolumes = phypStoragePoolListVolumes,
|
2010-06-24 21:39:27 +00:00
|
|
|
|
2010-06-24 21:15:43 +00:00
|
|
|
.volLookupByName = phypVolumeLookupByName,
|
2010-06-24 21:39:27 +00:00
|
|
|
.volLookupByKey = NULL,
|
2010-06-24 21:15:43 +00:00
|
|
|
.volLookupByPath = phypVolumeLookupByPath,
|
|
|
|
.volCreateXML = phypStorageVolCreateXML,
|
2010-06-24 21:39:27 +00:00
|
|
|
.volCreateXMLFrom = NULL,
|
|
|
|
.volDelete = NULL,
|
|
|
|
.volGetInfo = NULL,
|
2010-06-24 21:15:43 +00:00
|
|
|
.volGetXMLDesc = phypVolumeGetXMLDesc,
|
|
|
|
.volGetPath = phypVolumeGetPath,
|
2010-06-24 21:39:27 +00:00
|
|
|
.poolIsActive = NULL,
|
|
|
|
.poolIsPersistent = NULL
|
|
|
|
};
|
|
|
|
|
2011-03-28 20:07:20 +00:00
|
|
|
static virInterfaceDriver phypInterfaceDriver = {
|
2010-08-12 14:33:12 +00:00
|
|
|
.name = "PHYP",
|
|
|
|
.open = phypVIOSDriverOpen,
|
|
|
|
.close = phypVIOSDriverClose,
|
2011-03-28 20:07:20 +00:00
|
|
|
.numOfInterfaces = phypNumOfInterfaces,
|
|
|
|
.listInterfaces = phypListInterfaces,
|
|
|
|
.numOfDefinedInterfaces = NULL,
|
|
|
|
.listDefinedInterfaces = NULL,
|
|
|
|
.interfaceLookupByName = phypInterfaceLookupByName,
|
|
|
|
.interfaceLookupByMACString = NULL,
|
|
|
|
.interfaceGetXMLDesc = NULL,
|
|
|
|
.interfaceDefineXML = phypInterfaceDefineXML,
|
|
|
|
.interfaceUndefine = NULL,
|
|
|
|
.interfaceCreate = NULL,
|
|
|
|
.interfaceDestroy = phypInterfaceDestroy,
|
|
|
|
.interfaceIsActive = phypInterfaceIsActive
|
2010-08-12 14:33:12 +00:00
|
|
|
};
|
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
int
|
|
|
|
phypRegister(void)
|
|
|
|
{
|
2010-06-24 21:39:27 +00:00
|
|
|
if (virRegisterDriver(&phypDriver) < 0)
|
|
|
|
return -1;
|
|
|
|
if (virRegisterStorageDriver(&phypStorageDriver) < 0)
|
|
|
|
return -1;
|
2011-03-28 20:07:20 +00:00
|
|
|
if (virRegisterInterfaceDriver(&phypInterfaceDriver) < 0)
|
2010-08-12 14:33:12 +00:00
|
|
|
return -1;
|
2010-06-24 21:39:27 +00:00
|
|
|
|
2009-11-05 16:18:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|