All the comments from the previous email from Eric Blake are now fixed. Also
fixed some styling by using indent on the whole file. Hope we can get this
patch pushed to 0.8.2.
Any additional comments are always welcome.
[]'s
---
src/phyp/phyp_driver.c | 395 +++++++++++++++++++++++++++---------------------
src/phyp/phyp_driver.h | 23 ++--
2 files changed, 239 insertions(+), 179 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 77a74ef..f39c8fb 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -656,7 +656,8 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int
lpar_id,
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",
+ 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);
@@ -722,7 +723,8 @@ phypGetLparCPUGeneric(virConnectPtr conn, const char *managed_system,
virBufferAddLit(&buf, "lshwres");
if (system_type == HMC)
virBufferVSprintf(&buf, " -m %s", managed_system);
- virBufferVSprintf(&buf, " -r proc --level lpar -F %s --filter
lpar_ids=%d",
+ virBufferVSprintf(&buf,
+ " -r proc --level lpar -F %s --filter lpar_ids=%d",
type ? "curr_max_procs" : "curr_procs",
lpar_id);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
@@ -773,8 +775,7 @@ phypGetRemoteSlot(virConnectPtr conn, const char *managed_system,
if (system_type == HMC)
virBufferVSprintf(&buf, " -m %s", managed_system);
virBufferVSprintf(&buf, " -r virtualio --rsubtype scsi -F "
- "remote_slot_num --filter lpar_names=%s",
- lpar_name);
+ "remote_slot_num --filter lpar_names=%s", lpar_name);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
@@ -1067,7 +1068,8 @@ phypNumDomainsGeneric(virConnectPtr conn, unsigned int type)
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);
+ virBufferVSprintf(&buf, " -F lpar_id,state %s |grep -c
'^[0-9]*'",
+ state);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
@@ -1141,7 +1143,8 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids,
virBufferAddLit(&buf, "lssyscfg -r lpar");
if (system_type == HMC)
virBufferVSprintf(&buf, " -m %s", managed_system);
- virBufferVSprintf(&buf, " -F lpar_id,state %s | sed -e
's/,.*$//'", state);
+ virBufferVSprintf(&buf, " -F lpar_id,state %s | sed -e
's/,.*$//'",
+ state);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
@@ -1744,24 +1747,28 @@ phypGetVIOSNextSlotNumber(virConnectPtr conn)
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!(profile = phypGetLparProfile(conn, vios_id))) {
- VIR_ERROR("%s", "Unable to get VIOS profile name.");
+ VIR_ERROR0(_("Unable to get VIOS profile name."));
goto err;
}
virBufferAddLit(&buf, "echo $((`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` +1 ))", profile);
+ "|sort|tail -n 1|sed -s 's/^[0]//'` +1 ))",
profile);
+
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
return -1;
}
+
cmd = virBufferContentAndReset(&buf);
ret = phypExec(session, cmd, &exit_status, conn);
@@ -1802,17 +1809,17 @@ phypCreateServerSCSIAdapter(virConnectPtr conn)
if (!
(vios_name =
phypGetLparNAME(session, managed_system, vios_id, conn))) {
- VIR_ERROR("%s", "Unable to get VIOS name");
+ VIR_ERROR0(_("Unable to get VIOS name"));
goto err;
}
if (!(profile = phypGetLparProfile(conn, vios_id))) {
- VIR_ERROR("%s", "Unable to get VIOS profile name.");
+ VIR_ERROR0(_("Unable to get VIOS profile name."));
goto err;
}
if ((slot = phypGetVIOSNextSlotNumber(conn)) == -1) {
- VIR_ERROR("%s", "Unable to get free slot number");
+ VIR_ERROR0(_("Unable to get free slot number"));
goto err;
}
@@ -1823,7 +1830,7 @@ phypCreateServerSCSIAdapter(virConnectPtr conn)
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",
+ " -F virtual_scsi_adapters|sed -e s/\\\"//g",
vios_id, profile);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
@@ -1907,13 +1914,15 @@ phypGetVIOSFreeSCSIAdapter(virConnectPtr conn)
char *ret = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
managed_system, vios_id);
- virBufferVSprintf(&buf, "'lsmap -all -field svsa backing -fmt
,'");
- } else {
- virBufferVSprintf(&buf, "lsmap -all -field svsa backing -fmt ,");
- }
+
+ virBufferVSprintf(&buf, "lsmap -all -field svsa backing -fmt , ");
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
+
virBufferVSprintf(&buf, "|grep -v ',[^.*]'|head -n 1|sed -e
's/,//g'");
if (virBufferError(&buf)) {
@@ -1965,6 +1974,18 @@ phypAttachDevice(virDomainPtr domain, const char *xml)
virDomainDeviceDefPtr dev = NULL;
virDomainDefPtr def = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
+ char *domain_name = NULL;
+
+ if (VIR_ALLOC_N(domain_name, sizeof(domain->name)) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+
+ if (escape_specialcharacters
+ (domain->name, domain_name, strlen(domain->name)) == -1) {
+ virReportOOMError();
+ goto err;
+ }
def->os.type = strdup("aix");
@@ -1983,7 +2004,7 @@ phypAttachDevice(virDomainPtr domain, const char *xml)
if (!
(vios_name =
phypGetLparNAME(session, managed_system, vios_id, conn))) {
- VIR_ERROR("%s", "Unable to get VIOS name");
+ VIR_ERROR0(_("Unable to get VIOS name"));
goto err;
}
@@ -1993,31 +2014,32 @@ phypAttachDevice(virDomainPtr domain, const char *xml)
/* If not found, let's create one.
* */
if (phypCreateServerSCSIAdapter(conn) == -1) {
- VIR_ERROR("%s", "Unable to create new virtual adapter");
+ VIR_ERROR0(_("Unable to create new virtual adapter"));
goto err;
} else {
if (!(scsi_adapter = phypGetVIOSFreeSCSIAdapter(conn))) {
- VIR_ERROR("%s", "Unable to create new virtual
adapter");
+ VIR_ERROR0(_("Unable to create new virtual adapter"));
goto err;
}
}
}
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ 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);
- } else {
- virBufferVSprintf(&buf, "mkvdev -vdev %s -vadapter %s",
- dev->data.disk->src, scsi_adapter);
- }
+
+ virBufferVSprintf(&buf, "mkvdev -vdev %s -vadapter %s",
+ dev->data.disk->src, scsi_adapter);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
return -1;
}
+
cmd = virBufferContentAndReset(&buf);
ret = phypExec(session, cmd, &exit_status, conn);
@@ -2026,7 +2048,7 @@ phypAttachDevice(virDomainPtr domain, const char *xml)
goto err;
if (!(profile = phypGetLparProfile(conn, domain->id))) {
- VIR_ERROR("%s", "Unable to get VIOS profile name.");
+ VIR_ERROR0(_("Unable to get VIOS profile name."));
goto err;
}
@@ -2084,7 +2106,7 @@ phypAttachDevice(virDomainPtr domain, const char *xml)
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,
+ domain_name, domain->id, ret, slot,
vios_id, vios_name);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
@@ -2106,7 +2128,7 @@ phypAttachDevice(virDomainPtr domain, const char *xml)
virBufferVSprintf(&buf, " -m %s ", managed_system);
virBufferVSprintf(&buf,
" -p %s -o a -s %d -d 0 -a
\"adapter_type=server\"",
- domain->name, slot);
+ domain_name, slot);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
@@ -2271,7 +2293,7 @@ virStorageDriver phypStorageDriver = {
.volLookupByName = phypVolumeLookupByName,
.volLookupByKey = NULL,
.volLookupByPath = phypVolumeLookupByPath,
- .volCreateXML = NULL,
+ .volCreateXML = phypStorageVolCreateXML,
.volCreateXMLFrom = NULL,
.volDelete = NULL,
.volGetInfo = NULL,
@@ -2296,13 +2318,15 @@ phypVolumeGetKey(virConnectPtr conn, char *key, const char *name)
char *ret = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
managed_system, vios_id);
- virBufferVSprintf(&buf, "'lslv %s -field lvid'", name);
- } else {
- virBufferVSprintf(&buf, "lslv %s -field lvid", name);
- }
+
+ virBufferVSprintf(&buf, "lslv %s -field lvid", name);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
+
virBufferVSprintf(&buf, "|sed -e 's/^LV IDENTIFIER://' -e 's/\\
//g'");
if (virBufferError(&buf)) {
@@ -2310,6 +2334,7 @@ phypVolumeGetKey(virConnectPtr conn, char *key, const char *name)
virReportOOMError();
return -1;
}
+
cmd = virBufferContentAndReset(&buf);
ret = phypExec(session, cmd, &exit_status, conn);
@@ -2322,7 +2347,7 @@ phypVolumeGetKey(virConnectPtr conn, char *key, const char *name)
if (char_ptr)
*char_ptr = '\0';
- if (memmove(key, ret, PATH_MAX) == NULL)
+ if (memcpy(key, ret, MAX_KEY_SIZE) == NULL)
goto err;
VIR_FREE(cmd);
@@ -2349,20 +2374,23 @@ phypGetStoragePoolDevice(virConnectPtr conn, char *name)
char *ret = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ 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);
- } else {
- virBufferVSprintf(&buf, "lssp -detail -sp %s -field name", name);
- }
- virBufferVSprintf(&buf, "|sed '1d'|sed -e 's/\\
//g'");
+
+ virBufferVSprintf(&buf, "lssp -detail -sp %s -field name", name);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&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);
@@ -2400,20 +2428,23 @@ phypGetStoragePoolSize(virConnectPtr conn, char *name)
char *char_ptr;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ 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);
- } else {
- virBufferVSprintf(&buf, "lssp -detail -sp %s -field size", name);
- }
- virBufferVSprintf(&buf, "|sed '1d'|sed -e 's/\\
//g'");
+
+ virBufferVSprintf(&buf, "lssp -detail -sp %s -field size", name);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&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);
@@ -2449,27 +2480,27 @@ phypBuildVolume(virConnectPtr conn, const char *lvname, const char
*spname,
int exit_status = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ 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);
- } else {
- virBufferVSprintf(&buf, "mklv -lv %s %s %d", lvname, spname,
- capacity);
- }
+
+ virBufferVSprintf(&buf, "mklv -lv %s %s %d", lvname, spname,
capacity);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&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("%s\"%s\"", "Unable to create Volume. Reason:
", ret);
+ VIR_ERROR(_("unable to create Volume. Reason: %s"), ret);
goto err;
}
@@ -2487,9 +2518,10 @@ phypBuildVolume(virConnectPtr conn, const char *lvname, const char
*spname,
}
virStorageVolPtr
-phypStorageVolCreateXML(virStoragePoolPtr pool, const char *xml,
- unsigned int flags ATTRIBUTE_UNUSED)
+phypStorageVolCreateXML(virStoragePoolPtr pool,
+ const char *xml, unsigned int flags)
{
+ virCheckFlags(0, NULL);
virStorageVolDefPtr voldef = NULL;
virStoragePoolDefPtr spdef = NULL;
@@ -2501,7 +2533,7 @@ phypStorageVolCreateXML(virStoragePoolPtr pool, const char *xml,
return NULL;
}
- if (VIR_ALLOC_N(key, PATH_MAX) < 0) {
+ if (VIR_ALLOC_N(key, MAX_KEY_SIZE) < 0) {
virReportOOMError();
return NULL;
}
@@ -2511,18 +2543,18 @@ phypStorageVolCreateXML(virStoragePoolPtr pool, const char *xml,
if (pool->name != NULL) {
spdef->name = pool->name;
} else {
- VIR_ERROR("%s", "Unable to determine storage pool's
name.");
+ VIR_ERROR0(_("Unable to determine storage pool's name."));
goto err;
}
- if (memmove(spdef->uuid, pool->uuid, VIR_UUID_BUFLEN) == NULL) {
- VIR_ERROR("%s", "Unable to determine storage pool's
uuid.");
+ 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_ERROR("%s", "Unable to determine storage pools's
size.");
+ VIR_ERROR0(_("Unable to determine storage pools's size."));
goto err;
}
@@ -2535,19 +2567,19 @@ phypStorageVolCreateXML(virStoragePoolPtr pool, const char *xml,
/*XXX source adapter not working properly, should show hdiskX */
if ((spdef->source.adapter =
phypGetStoragePoolDevice(pool->conn, pool->name)) == NULL) {
- VIR_ERROR("%s",
- "Unable to determine storage pools's source adapter.");
+ VIR_ERROR0(_
+ ("Unable to determine storage pools's source
adapter."));
goto err;
}
if ((voldef = virStorageVolDefParseString(spdef, xml)) == NULL) {
- VIR_ERROR("%s", "Error parsing volume XML.");
+ VIR_ERROR0(_("Error parsing volume XML."));
goto err;
}
/* checking if this name already exists on this system */
if (phypVolumeLookupByName(pool, voldef->name) != NULL) {
- VIR_ERROR("%s", "StoragePool name already exists.");
+ VIR_ERROR0(_("StoragePool name already exists."));
goto err;
}
@@ -2555,13 +2587,13 @@ phypStorageVolCreateXML(virStoragePoolPtr pool, const char *xml,
* in the moment you create the volume.
* */
if (voldef->key) {
- VIR_ERROR("%s",
- "Key must be empty, Power Hypervisor will create one for
you.");
+ VIR_ERROR0(_
+ ("Key must be empty, Power Hypervisor will create one for
you."));
goto err;
}
if (voldef->capacity) {
- VIR_ERROR("%s", "Capacity cannot be empty.");
+ VIR_ERROR0(_("Capacity cannot be empty."));
goto err;
}
@@ -2600,13 +2632,15 @@ phypVolumeGetPhysicalVolumeByStoragePool(virStorageVolPtr vol,
char *sp)
char *ret = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ 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);
- } else {
- virBufferVSprintf(&buf, "lssp -detail -sp %s -field pvname", sp);
- }
+
+ virBufferVSprintf(&buf, "lssp -detail -sp %s -field pvname", sp);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
+
virBufferVSprintf(&buf, "|sed 1d");
if (virBufferError(&buf)) {
@@ -2614,6 +2648,7 @@ phypVolumeGetPhysicalVolumeByStoragePool(virStorageVolPtr vol, char
*sp)
virReportOOMError();
return NULL;
}
+
cmd = virBufferContentAndReset(&buf);
ret = phypExec(session, cmd, &exit_status, conn);
@@ -2651,21 +2686,23 @@ phypVolumeLookupByPath(virConnectPtr conn, const char *volname)
char *key = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
managed_system, vios_id);
- virBufferVSprintf(&buf, "'lslv %s -field vgname'",
volname);
- } else {
- virBufferVSprintf(&buf, "lslv %s -field vgname", volname);
- }
- virBufferVSprintf(&buf,
- "|sed -e 's/^VOLUME\\ GROUP://g' -e 's/\\
//g'");
+
+ virBufferVSprintf(&buf, "lslv %s -field vgname", volname);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&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);
@@ -2678,7 +2715,7 @@ phypVolumeLookupByPath(virConnectPtr conn, const char *volname)
if (char_ptr)
*char_ptr = '\0';
- if (VIR_ALLOC_N(key, PATH_MAX) < 0) {
+ if (VIR_ALLOC_N(key, MAX_KEY_SIZE) < 0) {
virReportOOMError();
return NULL;
}
@@ -2690,9 +2727,10 @@ phypVolumeLookupByPath(virConnectPtr conn, const char *volname)
}
char *
-phypVolumeGetXMLDesc(virStorageVolPtr vol,
- unsigned int flags ATTRIBUTE_UNUSED)
+phypVolumeGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
{
+ virCheckFlags(0, NULL);
+
virStorageVolDef voldef;
memset(&voldef, 0, sizeof(virStorageVolDef));
@@ -2705,7 +2743,7 @@ phypVolumeGetXMLDesc(virStorageVolPtr vol,
virStoragePoolDef pool;
memset(&pool, 0, sizeof(virStoragePoolDef));
- if (VIR_ALLOC_N(voldef.key, PATH_MAX) < 0) {
+ if (VIR_ALLOC_N(voldef.key, MAX_KEY_SIZE) < 0) {
virReportOOMError();
return NULL;
}
@@ -2713,17 +2751,17 @@ phypVolumeGetXMLDesc(virStorageVolPtr vol,
if (sp->name != NULL) {
pool.name = sp->name;
} else {
- VIR_ERROR("%s", "Unable to determine storage sp's
name.");
+ VIR_ERROR0(_("Unable to determine storage sp's name."));
goto err;
}
if (memmove(pool.uuid, sp->uuid, VIR_UUID_BUFLEN) == NULL) {
- VIR_ERROR("%s", "Unable to determine storage sp's
uuid.");
+ VIR_ERROR0(_("Unable to determine storage sp's uuid."));
goto err;
}
if ((pool.capacity = phypGetStoragePoolSize(sp->conn, sp->name)) == -1) {
- VIR_ERROR("%s", "Unable to determine storage sps's
size.");
+ VIR_ERROR0(_("Unable to determine storage sps's size."));
goto err;
}
@@ -2735,20 +2773,19 @@ phypVolumeGetXMLDesc(virStorageVolPtr vol,
if ((pool.source.adapter =
phypGetStoragePoolDevice(sp->conn, sp->name)) == NULL) {
- VIR_ERROR("%s",
- "Unable to determine storage sps's source adapter.");
+ VIR_ERROR0(_("Unable to determine storage sps's source
adapter."));
goto err;
}
if (vol->name != NULL)
voldef.name = vol->name;
else {
- VIR_ERROR("%s", "Unable to determine storage pool's
name.");
+ VIR_ERROR0(_("Unable to determine storage pool's name."));
goto err;
}
- if (memmove(voldef.key, vol->key, PATH_MAX) == NULL) {
- VIR_ERROR("%s", "Unable to determine volume's key.");
+ if (memmove(voldef.key, vol->key, MAX_KEY_SIZE) == NULL) {
+ VIR_ERROR0(_("Unable to determine volume's key."));
goto err;
}
@@ -2784,13 +2821,15 @@ phypVolumeGetPath(virStorageVolPtr vol)
char *path = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
managed_system, vios_id);
- virBufferVSprintf(&buf, "'lslv %s -field vgname'",
vol->name);
- } else {
- virBufferVSprintf(&buf, "lslv %s -field vgname", vol->name);
- }
+
+ virBufferVSprintf(&buf, "lslv %s -field vgname", vol->name);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
+
virBufferVSprintf(&buf,
"|sed -e 's/^VOLUME\\ GROUP://g' -e 's/\\
//g'");
@@ -2799,6 +2838,7 @@ phypVolumeGetPath(virStorageVolPtr vol)
virReportOOMError();
return NULL;
}
+
cmd = virBufferContentAndReset(&buf);
sp = phypExec(session, cmd, &exit_status, conn);
@@ -2837,7 +2877,7 @@ virStorageVolPtr
phypVolumeLookupByName(virStoragePoolPtr pool, const char *volname)
{
- char key[PATH_MAX];
+ char key[MAX_KEY_SIZE];
if (phypVolumeGetKey(pool->conn, key, volname) == -1)
return NULL;
@@ -2865,14 +2905,16 @@ phypStoragePoolListVolumes(virStoragePoolPtr pool, char **const
volumes,
char *char_ptr2 = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ 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);
- } else {
- virBufferVSprintf(&buf, "lsvg -lv %s -field lvname",
pool->name);
- }
- virBufferVSprintf(&buf, "|sed '1d'|sed '1d'");
+
+ virBufferVSprintf(&buf, "lsvg -lv %s -field lvname", pool->name);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
+
+ virBufferVSprintf(&buf, "|sed '1,2d'");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
@@ -2941,7 +2983,7 @@ phypStoragePoolNumOfVolumes(virStoragePoolPtr pool)
} else {
virBufferVSprintf(&buf, "lsvg -lv %s -field lvname",
pool->name);
}
- virBufferVSprintf(&buf, "|sed '1d'|sed '1d'|grep -c
'^.*$'");
+ virBufferVSprintf(&buf, "grep -c '^.*$'");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
@@ -2958,6 +3000,9 @@ phypStoragePoolNumOfVolumes(virStoragePoolPtr pool)
if (virStrToLong_i(ret, &char_ptr, 10, &nvolumes) == -1)
goto err;
+ /* We need to remove 2 line from the header text output */
+ nvolumes -= 2;
+
VIR_FREE(cmd);
VIR_FREE(ret);
return nvolumes;
@@ -2983,19 +3028,21 @@ phypDestroyStoragePool(virStoragePoolPtr pool)
int exit_status = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
managed_system, vios_id);
- virBufferVSprintf(&buf, "'rmsp %s'", pool->name);
- } else {
- virBufferVSprintf(&buf, "'rmsp %s'", pool->name);
- }
+
+ virBufferVSprintf(&buf, "rmsp %s", pool->name);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
return -1;
}
+
cmd = virBufferContentAndReset(&buf);
if (virAsprintf(&cmd,
@@ -3009,8 +3056,7 @@ phypDestroyStoragePool(virStoragePoolPtr pool)
ret = phypExec(session, cmd, &exit_status, conn);
if (exit_status < 0) {
- VIR_ERROR("%s\"%s\"", "Unable to create Storage Pool.
Reason: ",
- ret);
+ VIR_ERROR(_("Unable to create Storage Pool. Reason: %s"), ret);
goto err;
}
@@ -3039,28 +3085,28 @@ phypBuildStoragePool(virConnectPtr conn, virStoragePoolDefPtr
def)
int exit_status = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ 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);
- } else {
- virBufferVSprintf(&buf, "mksp -f %schild %s", def->name,
- source.adapter);
- }
+
+ virBufferVSprintf(&buf, "mksp -f %schild %s", def->name,
+ source.adapter);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&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("%s\"%s\"", "Unable to create Storage Pool.
Reason: ",
- ret);
+ VIR_ERROR(_("Unable to create Storage Pool. Reason: %s"), ret);
goto err;
}
@@ -3077,9 +3123,9 @@ phypBuildStoragePool(virConnectPtr conn, virStoragePoolDefPtr def)
virStoragePoolPtr
phypStoragePoolCreateXML(virConnectPtr conn,
- const char *xml,
- unsigned int flags ATTRIBUTE_UNUSED)
+ const char *xml, unsigned int flags)
{
+ virCheckFlags(0, NULL);
virStoragePoolDefPtr def = NULL;
virStoragePoolPtr sp = NULL;
@@ -3115,31 +3161,32 @@ phypStoragePoolCreateXML(virConnectPtr conn,
}
char *
-phypGetStoragePoolXMLDesc(virStoragePoolPtr pool,
- unsigned int flags ATTRIBUTE_UNUSED)
+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_ERROR("%s", "Unable to determine storage pool's
name.");
+ VIR_ERROR0(_("Unable to determine storage pool's name."));
goto err;
}
if (memmove(def.uuid, pool->uuid, VIR_UUID_BUFLEN) == NULL) {
- VIR_ERROR("%s", "Unable to determine storage pool's
uuid.");
+ VIR_ERROR0(_("Unable to determine storage pool's uuid."));
goto err;
}
if ((def.capacity =
phypGetStoragePoolSize(pool->conn, pool->name)) == -1) {
- VIR_ERROR("%s", "Unable to determine storage pools's
size.");
+ VIR_ERROR0(_("Unable to determine storage pools's size."));
goto err;
}
- /* Information not avaliable */
+ /* Information not available */
def.allocation = 0;
def.available = 0;
@@ -3148,8 +3195,8 @@ phypGetStoragePoolXMLDesc(virStoragePoolPtr pool,
/*XXX source adapter not working properly, should show hdiskX */
if ((def.source.adapter =
phypGetStoragePoolDevice(pool->conn, pool->name)) == NULL) {
- VIR_ERROR("%s",
- "Unable to determine storage pools's source adapter.");
+ VIR_ERROR0(_
+ ("Unable to determine storage pools's source
adapter."));
goto err;
}
@@ -3174,20 +3221,23 @@ phypGetStoragePoolUUID(virConnectPtr conn, unsigned char *uuid,
char *ret = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ 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);
- } else {
- virBufferVSprintf(&buf, "lsdev -dev %s -attr vgserial_id", name);
- }
- virBufferVSprintf(&buf, "|sed '1d'|sed '1d'");
+
+ virBufferVSprintf(&buf, "lsdev -dev %s -attr vgserial_id", name);
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
+
+ virBufferVSprintf(&buf, "|sed '1,2d'");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
return -1;
}
+
cmd = virBufferContentAndReset(&buf);
ret = phypExec(session, cmd, &exit_status, conn);
@@ -3248,7 +3298,7 @@ phypGetStoragePoolLookUpByUUID(virConnectPtr conn,
if (phypGetStoragePoolUUID(conn, local_uuid, pools[i]) == -1)
continue;
- if (STREQLEN((char *) local_uuid, (char *) uuid, VIR_UUID_BUFLEN)) {
+ if (!memcmp(local_uuid, uuid, VIR_UUID_BUFLEN)) {
sp = virGetStoragePool(conn, pools[i], uuid);
VIR_FREE(local_uuid);
VIR_FREE(pools);
@@ -3293,20 +3343,23 @@ phypNumOfStoragePools(virConnectPtr conn)
char *char_ptr;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
managed_system, vios_id);
- virBufferVSprintf(&buf, "'lsvg'");
- } else {
- virBufferVSprintf(&buf, "lsvg");
- }
- virBufferVSprintf(&buf, "grep -c '^.*$'");
+
+ virBufferVSprintf(&buf, "lsvg");
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
+
+ virBufferVSprintf(&buf, "|grep -c '^.*$'");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
return -1;
}
+
cmd = virBufferContentAndReset(&buf);
ret = phypExec(session, cmd, &exit_status, conn);
@@ -3345,19 +3398,21 @@ phypListStoragePools(virConnectPtr conn, char **const pools, int
npools)
char *char_ptr2 = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (system_type == HMC) {
- virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c ",
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "viosvrcmd -m %s --id %d -c '",
managed_system, vios_id);
- virBufferVSprintf(&buf, "'lsvg'");
- } else {
- virBufferVSprintf(&buf, "lsvg");
- }
+
+ virBufferVSprintf(&buf, "lsvg");
+
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, "\'");
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
return -1;
}
+
cmd = virBufferContentAndReset(&buf);
ret = phypExec(session, cmd, &exit_status, conn);
@@ -3395,6 +3450,7 @@ phypListStoragePools(virConnectPtr conn, char **const pools, int
npools)
VIR_FREE(ret);
return -1;
}
+
virDrvOpenStatus
phypStorageOpen(virConnectPtr conn ATTRIBUTE_UNUSED,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
@@ -3428,7 +3484,8 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
virBufferVSprintf(&buf, " -r lpar -p %s -i min_mem=%d,desired_mem=%d,"
"max_mem=%d,desired_procs=%d,virtual_scsi_adapters=%s",
def->name, (int) def->memory, (int) def->memory,
- (int) def->maxmem, (int) def->vcpus,
def->disks[0]->src);
+ (int) def->maxmem, (int) def->vcpus,
+ def->disks[0]->src);
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
@@ -3755,7 +3812,7 @@ phypUUIDTable_Push(virConnectPtr conn)
/* end of file */
break;
} else {
- VIR_ERROR(_("Failed to read from '%s'"), local_file);
+ VIR_ERROR(_("Failed to read from %s"), local_file);
goto err;
}
}
diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h
index 2606fe4..c83ccd1 100644
--- a/src/phyp/phyp_driver.h
+++ b/src/phyp/phyp_driver.h
@@ -27,6 +27,7 @@
#include <config.h>
#include <libssh2.h>
+#define MAX_KEY_SIZE (1024*4)
#define LPAR_EXEC_ERR -1
#define SSH_CONN_ERR -2 /* error while trying to connect to remote host */
#define SSH_CMD_ERR -3 /* error while trying to execute the remote cmd */
@@ -80,13 +81,13 @@ struct _phyp_driver {
* Storage functions
* */
virStorageVolPtr
-phypStorageVolCreateXML(virStoragePoolPtr pool, const char *xmldesc,
- unsigned int flags ATTRIBUTE_UNUSED);
+phypStorageVolCreateXML(virStoragePoolPtr pool,
+ const char *xml, unsigned int flags);
-virStorageVolPtr phypVolumeLookupByPath (virConnectPtr pool, const char *path);
+virStorageVolPtr phypVolumeLookupByPath(virConnectPtr pool,
+ const char *path);
-char *phypVolumeGetXMLDesc(virStorageVolPtr vol,
- unsigned int flags ATTRIBUTE_UNUSED);
+char *phypVolumeGetXMLDesc(virStorageVolPtr vol, unsigned int flags);
char *phypVolumeGetPath(virStorageVolPtr vol);
@@ -102,19 +103,21 @@ int phypDestroyStoragePool(virStoragePoolPtr pool);
virStoragePoolPtr phypStoragePoolCreateXML(virConnectPtr conn,
const char *xml,
- unsigned int flags
- ATTRIBUTE_UNUSED);
+ unsigned int flags);
int phypNumOfStoragePools(virConnectPtr conn);
int phypListStoragePools(virConnectPtr conn, char **const pools,
int npools);
-virStoragePoolPtr phypStoragePoolLookupByName(virConnectPtr conn, const char *name);
+virStoragePoolPtr phypStoragePoolLookupByName(virConnectPtr conn,
+ const char *name);
-virStoragePoolPtr phypGetStoragePoolLookUpByUUID(virConnectPtr conn, const unsigned char
*uuid);
+virStoragePoolPtr phypGetStoragePoolLookUpByUUID(virConnectPtr conn, const unsigned char
+ *uuid);
-char * phypGetStoragePoolXMLDesc(virStoragePoolPtr pool, unsigned int flags);
+char *phypGetStoragePoolXMLDesc(virStoragePoolPtr pool,
+ unsigned int flags);
virDrvOpenStatus phypStorageOpen(virConnectPtr conn ATTRIBUTE_UNUSED,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
--
1.7.0.4