Hello again,
This is the life cycle operations I've been working on these days.
Fortunately this is a smaller and more punctual diff. :)
Any comment is always welcome.
[]'s
On Mon, 2009-06-22 at 18:57 -0300, Eduardo Otubo wrote:
> Hello all,
>
> This is the initial patch for the driver for IBM Power Hypervisors. The
> minimum set of features are now implemented: list, list --all and
> dumpxml. Here is the Changeset since last PATCH I sent:
>
> * The URI has changed to: phyp://u...@[hmc|ivm]/managed_system. If the
> system is a HMC+VIOS based, only an HMC authentication will be required.
> Commands will be sent to VIOS trough HMC command line. And if the system
> is an IVM based, then just provide the username and password for IVM.
>
> * Since the Power Hypervisor has no information about UUID's, I built a
> little database (uuid_db) to store and associate LPAR ID's with UUID
> randomly generated by the API.
>
> * The command dumpxml is implemented, but there are some informations
> missing. Fetching informations like fstab, os type, uptime, IP addr and
> so on, will only be available in a future versions of the HMC system.
>
> * The TODO list is now set to implement life cycle functions.
>
>
> Thanks in advance,
> []'s
>
>
> --
> Libvir-list mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/libvir-list
--
Eduardo Otubo
Software Engineer
Linux Technology Center
IBM Systems & Technology Group
Mobile: +55 19 8135 0885
[email protected]
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index b922ab8..0b28cff 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -585,6 +585,64 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
}
int
+phypGetLparState(virConnectPtr conn, unsigned int lpar_id)
+{
+ ConnectionData *connection_data = conn->networkPrivateData;
+ SSH_SESSION *ssh_session = connection_data->session;
+ char *cmd;
+ int exit_status = 0;
+ char *char_ptr = NULL;
+ char *managed_system = conn->uri->path;
+
+ /* need to shift one byte in order to remove the first "/" of URI component */
+ if (managed_system[0] == '/')
+ 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 (virAsprintf(&cmd,
+ "lssyscfg -r lpar -m %s -F state --filter lpar_ids=%d",
+ managed_system, lpar_id) < 0) {
+ virReportOOMError(conn);
+ goto err;
+ }
+
+ char *ret = exec(ssh_session, cmd, (int *) exit_status, conn);
+
+ if (ret == NULL)
+ goto err;
+
+ char_ptr = strchr(ret, '\n');
+
+ if (char_ptr)
+ *char_ptr = '\0';
+
+ if (exit_status < 0 || ret == NULL)
+ goto err;
+
+ VIR_FREE(cmd);
+ if (STREQ(ret, "Running"))
+ return VIR_DOMAIN_RUNNING;
+ else if (STREQ(ret, "Not Activated"))
+ return VIR_DOMAIN_SHUTOFF;
+ else if (STREQ(ret, "Shutting Down"))
+ return VIR_DOMAIN_SHUTDOWN;
+ else
+ goto err;
+
+ err:
+ VIR_FREE(cmd);
+ return VIR_DOMAIN_NOSTATE;
+}
+
+int
phypDiskType(virConnectPtr conn, char *backing_device)
{
ConnectionData *connection_data = conn->networkPrivateData;
@@ -1000,6 +1058,119 @@ phypDomainDumpXML(virDomainPtr dom, int flags)
return ret;
}
+static int
+phypDomainResume(virDomainPtr dom)
+{
+ ConnectionData *connection_data = dom->conn->networkPrivateData;
+ SSH_SESSION *ssh_session = connection_data->session;
+ char *managed_system = dom->conn->uri->path;
+ int exit_status = 0;
+ char *char_ptr = NULL;
+ char *cmd;
+
+ /* need to shift one byte in order to remove the first "/" of URI component */
+ if (managed_system[0] == '/')
+ 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 (virAsprintf
+ (&cmd,
+ "chsysstate -m %s -r lpar -o on --id %d -f %s",
+ managed_system, dom->id, dom->name) < 0) {
+ virReportOOMError(dom->conn);
+ goto err;
+ }
+
+ char *ret = exec(ssh_session, cmd, &exit_status, dom->conn);
+
+ err:
+ VIR_FREE(cmd);
+ VIR_FREE(ret);
+ return 0;
+
+}
+
+static int
+phypDomainShutdown(virDomainPtr dom)
+{
+ ConnectionData *connection_data = dom->conn->networkPrivateData;
+ SSH_SESSION *ssh_session = connection_data->session;
+ char *managed_system = dom->conn->uri->path;
+ int exit_status = 0;
+ char *char_ptr = NULL;
+ char *cmd;
+
+ /* need to shift one byte in order to remove the first "/" of URI component */
+ if (managed_system[0] == '/')
+ 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 (virAsprintf
+ (&cmd,
+ "chsysstate -m %s -r lpar -o shutdown --id %d",
+ managed_system, dom->id) < 0) {
+ virReportOOMError(dom->conn);
+ goto err;
+ }
+
+ char *ret = exec(ssh_session, cmd, &exit_status, dom->conn);
+
+ err:
+ VIR_FREE(cmd);
+ VIR_FREE(ret);
+ return 0;
+
+}
+
+static int
+phypDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
+{
+ char *managed_system = dom->conn->uri->path;
+
+ /* need to shift one byte in order to remove the first "/" of uri component */
+ if (managed_system[0] == '/')
+ managed_system++;
+
+ /* here we are handling only the first component of the path,
+ * so skipping the second:
+ * */
+ char *char_ptr = strchr(managed_system, '/');
+
+ if (char_ptr)
+ *char_ptr = '\0';
+
+ info->state = phypGetLparState(dom->conn, dom->id);
+
+ if ((info->maxMem =
+ phypGetLparMem(dom->conn, managed_system, dom->id, 0)) == 0)
+ VIR_WARN("%s", "Unable to determine domain's max memory.");
+
+ if ((info->memory =
+ phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0)
+ VIR_WARN("%s", "Unable to determine domain's memory.");
+
+ if ((info->nrVirtCpu =
+ phypGetLparCPU(dom->conn, managed_system, dom->id)) == 0)
+ VIR_WARN("%s", "Unable to determine domain's CPU.");
+
+ return 0;
+
+}
+
virDriver phypDriver = {
VIR_DRV_PHYP,
"PHYP",
@@ -1019,15 +1190,15 @@ virDriver phypDriver = {
NULL, /* domainLookupByUUID */
phypDomainLookupByName, /* domainLookupByName */
NULL, /* domainSuspend */
- NULL, /* domainResume */
- NULL, /* domainShutdown */
+ phypDomainResume, /* domainResume */
+ phypDomainShutdown, /* domainShutdown */
NULL, /* domainReboot */
NULL, /* domainDestroy */
NULL, /* domainGetOSType */
NULL, /* domainGetMaxMemory */
NULL, /* domainSetMaxMemory */
NULL, /* domainSetMemory */
- NULL, /* domainGetInfo */
+ phypDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
NULL, /* domainCoreDump */
diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h
index 62ffbc5..f16b6fe 100644
--- a/src/phyp/phyp_driver.h
+++ b/src/phyp/phyp_driver.h
@@ -44,6 +44,8 @@ void stripNewline(char *striped_string, char *string);
int buffer_add_u8(struct buffer_struct *buffer, u8 data);
+int phypGetLparState(virConnectPtr conn, unsigned int lpar_id);
+
unsigned long phypGetLparMem(virConnectPtr conn,
const char *managed_system, int lpar_id,
int type);
--
Libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list