Fixing all pointed in the previous email. Thanks for all the comments. --- src/phyp/phyp_driver.c | 356 +++++++++++++++++++++++++++++++++--------------- src/phyp/phyp_driver.h | 8 + 2 files changed, 252 insertions(+), 112 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index c04a487..60e2493 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -66,6 +66,9 @@ virReportErrorHelper(NULL, VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \ __LINE__, __VA_ARGS__) +static unsigned const int HMC = 0; +static unsigned const int IVM = 127; + /* * URI: phyp://user@[hmc|ivm]/managed_system * */ @@ -82,7 +85,7 @@ phypOpen(virConnectPtr conn, uuid_tablePtr uuid_table = NULL; phyp_driverPtr phyp_driver = NULL; char *char_ptr; - char *managed_system; + char *managed_system = NULL; if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; @@ -96,12 +99,6 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } - if (conn->uri->path == NULL) { - PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing managed system name in phyp:// URI")); - return VIR_DRV_OPEN_ERROR; - } - if (VIR_ALLOC(phyp_driver) < 0) { virReportOOMError(); goto failure; @@ -117,36 +114,39 @@ phypOpen(virConnectPtr conn, goto failure; } - len = strlen(conn->uri->path) + 1; + if (conn->uri->path) { + len = strlen(conn->uri->path) + 1; - if (VIR_ALLOC_N(string, len) < 0) { - virReportOOMError(); - goto failure; - } + if (VIR_ALLOC_N(string, len) < 0) { + virReportOOMError(); + goto failure; + } - /* 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); + /* 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); - if (!managed_system) { - virReportOOMError(); - goto failure; - } + 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, '/'); + /* 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'; + if (char_ptr) + *char_ptr = '\0'; - if (escape_specialcharacters(conn->uri->path, string, len) == -1) { - PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, - "%s", _("Error parsing 'path'. Invalid characters.")); - goto failure; + if (escape_specialcharacters(conn->uri->path, string, len) == -1) { + PHYP_ERROR(VIR_ERR_INTERNAL_ERROR, + "%s", + _("Error parsing 'path'. Invalid characters.")); + goto failure; + } } if ((session = openSSHSession(conn, auth, &internal_socket)) == NULL) { @@ -160,7 +160,9 @@ phypOpen(virConnectPtr conn, uuid_table->nlpars = 0; uuid_table->lpars = NULL; - phyp_driver->managed_system = managed_system; + if (conn->uri->path) + phyp_driver->managed_system = managed_system; + phyp_driver->uuid_table = uuid_table; if ((phyp_driver->caps = phypCapsInit()) == NULL) { virReportOOMError(); @@ -169,12 +171,18 @@ phypOpen(virConnectPtr conn, conn->privateData = phyp_driver; conn->networkPrivateData = connection_data; - if (phypUUIDTable_Init(conn) == -1) + + if ((phyp_driver->system_type = phypGetSystemType(conn)) == -1) goto failure; - if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) + if (phypUUIDTable_Init(conn) == -1) goto failure; + if (phyp_driver->system_type == HMC) { + if ((phyp_driver->vios_id = phypGetVIOSPartitionID(conn)) == -1) + goto failure; + } + return VIR_DRV_OPEN_SUCCESS; failure: @@ -280,7 +288,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, username = virRequestUsername(auth, NULL, conn->uri->server); if (username == NULL) { - PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed")); + PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s", + _("Username request failed")); goto err; } } @@ -360,7 +369,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, password = virRequestPassword(auth, username, conn->uri->server); if (password == NULL) { - PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed")); + PHYP_ERROR(VIR_ERR_AUTH_FAILED, "%s", + _("Password request failed")); goto disconnect; } @@ -488,11 +498,45 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status, return virBufferContentAndReset(&tex_ret); } +static char * +hmc_helper(int system_type, const char *managed_system) +{ + char *unsafe = NULL; + if (system_type == HMC) + virAsprintf(&unsafe, "-m %s", managed_system); + else + unsafe[0] = 0; + return unsafe; +} + +int +phypGetSystemType(virConnectPtr conn) +{ + ConnectionData *connection_data = conn->networkPrivateData; + LIBSSH2_SESSION *session = connection_data->session; + char *cmd = NULL; + char *ret = NULL; + int exit_status = 0; + + if (virAsprintf(&cmd, "lshmc -V") < 0) { + virReportOOMError(); + exit_status = -1; + } + ret = phypExec(session, cmd, &exit_status, conn); + + VIR_FREE(cmd); + VIR_FREE(ret); + return exit_status; +} + + /* return the lpar_id given a name and a managed system name */ static int phypGetLparID(LIBSSH2_SESSION * session, const char *managed_system, const char *name, virConnectPtr conn) { + phyp_driverPtr phyp_driver = conn->privateData; + int system_type = phyp_driver->system_type; int exit_status = 0; int lpar_id = 0; char *char_ptr; @@ -500,8 +544,8 @@ phypGetLparID(LIBSSH2_SESSION * session, const char *managed_system, char *ret = NULL; if (virAsprintf(&cmd, - "lssyscfg -r lpar -m %s --filter lpar_names=%s -F lpar_id", - managed_system, name) < 0) { + "lssyscfg -r lpar %s --filter lpar_names=%s -F lpar_id", + hmc_helper(system_type, managed_system), name) < 0) { virReportOOMError(); goto err; } @@ -529,13 +573,16 @@ static char * phypGetLparNAME(LIBSSH2_SESSION * session, const char *managed_system, unsigned int lpar_id, virConnectPtr conn) { + phyp_driverPtr phyp_driver = conn->privateData; + int system_type = phyp_driver->system_type; char *cmd = NULL; char *ret = NULL; int exit_status = 0; if (virAsprintf(&cmd, - "lssyscfg -r lpar -m %s --filter lpar_ids=%d -F name", - managed_system, lpar_id) < 0) { + "lssyscfg -r lpar %s --filter lpar_ids=%d -F name", + hmc_helper(system_type, managed_system), + lpar_id) < 0) { virReportOOMError(); goto err; } @@ -595,6 +642,8 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id, { 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; @@ -606,17 +655,19 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id, if (type) { if (virAsprintf(&cmd, - "lshwres -m %s -r mem --level lpar -F curr_mem " + "lshwres %s -r mem --level lpar -F curr_mem " "--filter lpar_ids=%d", - managed_system, lpar_id) < 0) { + hmc_helper(system_type, managed_system), + lpar_id) < 0) { virReportOOMError(); goto err; } } else { if (virAsprintf(&cmd, - "lshwres -m %s -r mem --level lpar -F " + "lshwres %s -r mem --level lpar -F " "curr_max_mem --filter lpar_ids=%d", - managed_system, lpar_id) < 0) { + hmc_helper(system_type, managed_system), + lpar_id) < 0) { virReportOOMError(); goto err; } @@ -667,6 +718,8 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, { 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; @@ -675,17 +728,19 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system, if (type) { if (virAsprintf(&cmd, - "lshwres -m %s -r proc --level lpar -F " + "lshwres %s -r proc --level lpar -F " "curr_max_procs --filter lpar_ids=%d", - managed_system, lpar_id) < 0) { + hmc_helper(system_type, managed_system), + lpar_id) < 0) { virReportOOMError(); goto err; } } else { if (virAsprintf(&cmd, - "lshwres -m %s -r proc --level lpar -F " + "lshwres %s -r proc --level lpar -F " "curr_procs --filter lpar_ids=%d", - managed_system, lpar_id) < 0) { + hmc_helper(system_type, managed_system), + lpar_id) < 0) { virReportOOMError(); goto err; } @@ -719,6 +774,8 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system, { 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; @@ -726,9 +783,10 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system, int exit_status = 0; if (virAsprintf(&cmd, - "lshwres -m %s -r virtualio --rsubtype scsi -F " + "lshwres %s -r virtualio --rsubtype scsi -F " "remote_slot_num --filter lpar_names=%s", - managed_system, lpar_name) < 0) { + hmc_helper(system_type, managed_system), + lpar_name) < 0) { virReportOOMError(); goto err; } @@ -761,6 +819,8 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system, { 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; int remote_slot = 0; @@ -773,9 +833,10 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system, goto err; if (virAsprintf(&cmd, - "lshwres -m %s -r virtualio --rsubtype scsi -F " + "lshwres %s -r virtualio --rsubtype scsi -F " "backing_devices --filter slots=%d", - managed_system, remote_slot) < 0) { + hmc_helper(system_type, managed_system), + remote_slot) < 0) { virReportOOMError(); goto err; } @@ -834,6 +895,7 @@ phypGetLparState(virConnectPtr conn, unsigned int lpar_id) 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; @@ -842,8 +904,9 @@ phypGetLparState(virConnectPtr conn, unsigned int lpar_id) int state = VIR_DOMAIN_NOSTATE; if (virAsprintf(&cmd, - "lssyscfg -r lpar -m %s -F state --filter lpar_ids=%d", - managed_system, lpar_id) < 0) { + "lssyscfg -r lpar %s -F state --filter lpar_ids=%d", + hmc_helper(system_type, managed_system), + lpar_id) < 0) { virReportOOMError(); goto cleanup; } @@ -877,6 +940,7 @@ phypGetVIOSPartitionID(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; char *cmd = NULL; char *ret = NULL; int exit_status = 0; @@ -885,8 +949,9 @@ phypGetVIOSPartitionID(virConnectPtr conn) char *managed_system = phyp_driver->managed_system; if (virAsprintf(&cmd, - "lssyscfg -m %s -r lpar -F lpar_id,lpar_env|grep " - "vioserver|sed -s 's/,.*$//g'", managed_system) < 0) { + "lssyscfg %s -r lpar -F lpar_id,lpar_env|grep " + "vioserver|sed -s 's/,.*$//g'", + hmc_helper(system_type, managed_system)) < 0) { virReportOOMError(); goto err; } @@ -915,6 +980,7 @@ phypDiskType(virConnectPtr conn, char *backing_device) phyp_driverPtr phyp_driver = conn->privateData; 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; @@ -924,9 +990,10 @@ phypDiskType(virConnectPtr conn, char *backing_device) int disk_type = -1; if (virAsprintf(&cmd, - "viosvrcmd -m %s -p %d -c \"lssp -field name type " + "viosvrcmd %s -p %d -c \"lssp -field name type " "-fmt , -all|grep %s|sed -e 's/^.*,//g'\"", - managed_system, vios_id, backing_device) < 0) { + hmc_helper(system_type, managed_system), vios_id, + backing_device) < 0) { virReportOOMError(); goto cleanup; } @@ -966,6 +1033,7 @@ 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; int ndom = 0; char *char_ptr; @@ -976,14 +1044,19 @@ phypNumDomainsGeneric(virConnectPtr conn, unsigned int type) if (type == 0) state = "|grep Running"; - else if (type == 1) - state = "|grep \"Not Activated\""; - else + else if (type == 1) { + if (system_type == HMC) { + state = "|grep \"Not Activated\""; + } else { + state = "|grep \"Open Firmware\""; + } + } else state = " "; if (virAsprintf(&cmd, - "lssyscfg -r lpar -m %s -F lpar_id,state %s |grep -c " - "^[0-9]*", managed_system, state) < 0) { + "lssyscfg -r lpar %s -F lpar_id,state %s |grep -c " + "^[0-9]*", hmc_helper(system_type, + managed_system), state) < 0) { virReportOOMError(); goto err; } @@ -1032,6 +1105,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, 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; @@ -1051,11 +1125,12 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids, if (virAsprintf (&cmd, - "lssyscfg -r lpar -m %s -F lpar_id,state %s | sed -e 's/,.*$//g'", - managed_system, state) < 0) { + "lssyscfg -r lpar %s -F lpar_id,state %s | sed -e 's/,.*$//g'", + hmc_helper(system_type, managed_system), state) < 0) { virReportOOMError(); goto err; } + ret = phypExec(session, cmd, &exit_status, conn); /* I need to parse the textual return in order to get the ret */ @@ -1103,6 +1178,7 @@ phypListDefinedDomains(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 exit_status = 0; int got = 0; @@ -1114,8 +1190,9 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames) if (virAsprintf (&cmd, - "lssyscfg -r lpar -m %s -F name,state | grep \"Not Activated\" | " - "sed -e 's/,.*$//g'", managed_system) < 0) { + "lssyscfg -r lpar %s -F name,state | grep \"Not Activated\" | " + "sed -e 's/,.*$//g'", hmc_helper(system_type, + managed_system)) < 0) { virReportOOMError(); goto err; } @@ -1272,6 +1349,7 @@ phypDomainResume(virDomainPtr dom) 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; @@ -1279,8 +1357,9 @@ phypDomainResume(virDomainPtr dom) if (virAsprintf (&cmd, - "chsysstate -m %s -r lpar -o on --id %d -f %s", - managed_system, dom->id, dom->name) < 0) { + "chsysstate %s -r lpar -o on --id %d -f %s", + hmc_helper(system_type, managed_system), dom->id, + dom->name) < 0) { virReportOOMError(); goto err; } @@ -1304,8 +1383,10 @@ static int phypDomainShutdown(virDomainPtr dom) { ConnectionData *connection_data = dom->conn->networkPrivateData; - phyp_driverPtr phyp_driver = dom->conn->privateData; + 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; @@ -1313,12 +1394,11 @@ phypDomainShutdown(virDomainPtr dom) if (virAsprintf (&cmd, - "chsysstate -m %s -r lpar -o shutdown --id %d", - managed_system, dom->id) < 0) { + "chsysstate %s -r lpar -o shutdown --id %d", + hmc_helper(system_type, managed_system), dom->id) < 0) { virReportOOMError(); goto err; } - ret = phypExec(session, cmd, &exit_status, dom->conn); if (exit_status < 0) @@ -1363,16 +1443,25 @@ phypDomainDestroy(virDomainPtr dom) 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; - if (virAsprintf - (&cmd, - "rmsyscfg -m %s -r lpar --id %d", managed_system, dom->id) < 0) { - virReportOOMError(); - goto err; + if (system_type == HMC) { + if (virAsprintf + (&cmd, + "rmsyscfg -m %s -r lpar --id %d", managed_system, + dom->id) < 0) { + virReportOOMError(); + goto err; + } + } else { + if (virAsprintf(&cmd, "rmsyscfg -r lpar --id %d", dom->id) < 0) { + virReportOOMError(); + goto err; + } } ret = phypExec(session, cmd, &exit_status, dom->conn); @@ -1396,8 +1485,7 @@ phypDomainDestroy(virDomainPtr dom) static virDomainPtr phypDomainCreateAndStart(virConnectPtr conn, - const char *xml, - unsigned int flags) + const char *xml, unsigned int flags) { ConnectionData *connection_data = conn->networkPrivateData; @@ -1510,6 +1598,7 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) 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; @@ -1538,9 +1627,10 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) if (virAsprintf (&cmd, - "chhwres -r proc -m %s --id %d -o %c --procunits %d 2>&1 |sed" + "chhwres -r proc %s --id %d -o %c --procunits %d 2>&1 |sed" "-e 's/^.*\\([0-9]\\+.[0-9]\\+\\).*$/\\1/g'", - managed_system, dom->id, operation, amount) < 0) { + hmc_helper(system_type, managed_system), dom->id, operation, + amount) < 0) { virReportOOMError(); goto err; } @@ -1548,8 +1638,9 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) 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_ERROR0(_ + ("Possibly you don't have IBM Tools installed in your LPAR." + "Contact your support to enable this feature.")); goto err; } @@ -1566,9 +1657,7 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus) } virDriver phypDriver = { - VIR_DRV_PHYP, - "PHYP", - phypOpen, /* open */ + VIR_DRV_PHYP, "PHYP", phypOpen, /* open */ phypClose, /* close */ NULL, /* supports_feature */ NULL, /* type */ @@ -1647,23 +1736,23 @@ virDriver phypDriver = { NULL, /* domainIsPersistent */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ - NULL, /* domainGetJobInfo */ - NULL, /* domainAbortJob */ - NULL, /* domainMigrateSetMaxDowntime */ - 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 */ + NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ + NULL, /* domainMigrateSetMaxDowntime */ + 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 */ }; int @@ -1672,6 +1761,7 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) 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; @@ -1679,11 +1769,11 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) if (virAsprintf (&cmd, - "mksyscfg -m %s -r lpar -p %s -i min_mem=%d,desired_mem=%d," + "mksyscfg %s -r lpar -p %s -i min_mem=%d,desired_mem=%d," "max_mem=%d,desired_procs=%d,virtual_scsi_adapters=%s", - managed_system, def->name, (int) def->memory, - (int) def->memory, (int) def->maxmem, (int) def->vcpus, - def->disks[0]->src) < 0) { + hmc_helper(system_type, managed_system), def->name, + (int) def->memory, (int) def->memory, (int) def->maxmem, + (int) def->vcpus, def->disks[0]->src) < 0) { virReportOOMError(); goto err; } @@ -1799,7 +1889,8 @@ phypUUIDTable_ReadFile(virConnectPtr conn) } uuid_table->lpars[i]->id = id; } else { - VIR_WARN0("Unable to read from information to local file."); + VIR_WARN0 + ("Unable to read from information to local file."); goto err; } @@ -1950,14 +2041,33 @@ phypUUIDTable_Push(virConnectPtr conn) ConnectionData *connection_data = conn->networkPrivateData; LIBSSH2_SESSION *session = connection_data->session; 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 remote_file[] = "/home/hscroot/libvirt_uuid_table"; char local_file[] = "./uuid_table"; + char *remote_file = NULL; + + if (conn->uri->user != NULL) { + virBufferVSprintf(&username, "%s", conn->uri->user); + + if (virBufferError(&username)) { + virBufferFreeAndReset(&username); + virReportOOMError(); + goto err; + } + } + + if (virAsprintf + (&remote_file, "/home/%s/libvirt_uuid_table", + virBufferContentAndReset(&username)) + < 0) { + virReportOOMError(); + goto err; + } if (stat(local_file, &local_fileinfo) == -1) { VIR_WARN0("Unable to stat local file."); @@ -2015,6 +2125,7 @@ phypUUIDTable_Push(virConnectPtr conn) libssh2_channel_free(channel); channel = NULL; } + virBufferFreeAndReset(&username); return 0; err: @@ -2034,6 +2145,7 @@ phypUUIDTable_Pull(virConnectPtr conn) ConnectionData *connection_data = conn->networkPrivateData; LIBSSH2_SESSION *session = connection_data->session; LIBSSH2_CHANNEL *channel = NULL; + virBuffer username = VIR_BUFFER_INITIALIZER; struct stat fileinfo; char buffer[1024]; int rc = 0; @@ -2042,8 +2154,26 @@ phypUUIDTable_Pull(virConnectPtr conn) int amount = 0; int total = 0; int sock = 0; - char remote_file[] = "/home/hscroot/libvirt_uuid_table"; char local_file[] = "./uuid_table"; + char *remote_file = NULL; + + if (conn->uri->user != NULL) { + virBufferVSprintf(&username, "%s", conn->uri->user); + + if (virBufferError(&username)) { + virBufferFreeAndReset(&username); + virReportOOMError(); + goto err; + } + } + + if (virAsprintf + (&remote_file, "/home/%s/libvirt_uuid_table", + virBufferContentAndReset(&username)) + < 0) { + virReportOOMError(); + goto err; + } /* Trying to stat the remote file. */ do { @@ -2075,7 +2205,8 @@ phypUUIDTable_Pull(virConnectPtr conn) 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."); + VIR_WARN0 + ("Unable to write information to local file."); got += rc; total += rc; @@ -2103,6 +2234,7 @@ phypUUIDTable_Pull(virConnectPtr conn) libssh2_channel_free(channel); channel = NULL; } + virBufferFreeAndReset(&username); return 0; err: diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h index f680994..80ff0c3 100644 --- a/src/phyp/phyp_driver.h +++ b/src/phyp/phyp_driver.h @@ -66,11 +66,19 @@ struct _phyp_driver { uuid_tablePtr uuid_table; virCapsPtr caps; int vios_id; + + /* system_type: + * 0 = hmc + * 127 = ivm + * */ + int system_type; char *managed_system; }; int phypCheckSPFreeSapce(virConnectPtr conn, int required_size, char *sp); +int phypGetSystemType(virConnectPtr conn); + int phypGetVIOSPartitionID(virConnectPtr conn); virCapsPtr phypCapsInit(void); -- 1.7.0.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list