[libvirt] 1. Domain Destroy , 2. Domain boot on a different host and 3. Domain start time
by IKI-サガル バルウェ
Hello,
Firstly, I have some confusion about the libvirt API "virDomainDestroy"
method. here is the link to API:
http://libvirt.org/html/libvirt-libvirt.html#virDomainDestroy
Does this method completely removes the domain from the system? I have
confusion because the "virsh destroy" tool option performs a forced shutdown
and does not destroy/delete/remove the domain.
So, what does "virDomainDestroy" method do exactly? Also, if it comletely
removes the domain, then is there any other method to perform a force
shutdown of the domain. I know the "virDomainShutdown" method performs a
normal shutdown.
Secondly, Is it possible to boot a domain on a completely different physical
host with the same Hypervisor configuration?
For. E.g: if I have a domain on a host 192.168.101.1 running Xen with a
Domain "test" in shutdown state. If I have to start/boot the domain "test"
on a different physical host, running Xen say 192.168.101.2, is it possible
using libvirt API? If not, then is there any other method to do it?
Thirdly, Is there a method to get the total running time of a domain? I
mean, the amount of time since the domain had been booted. Currently, I can
fetch the CPU time. But, is this the exact amount of time the domain is ON?
i.e. If the domain is in a "IDLE" state, the CPU time does not increase. But
what I want is the amount of time the domain was ON(including the idle
time). So, If I can get the start time of the domain, I can calculate the
duration.
Sorry for the long mail and description.
Any help would be greatly appreciated.
Thanks and Regards
Sagar Barve
14 years, 5 months
[libvirt] [PATCH] virsh: add --uuid option to vol-pool
by Justin Clift
Adds an optional switch, --uuid, for telling the virsh vol-pool command
to return the pool UUID rather than pool name.
---
Just added for flexibility.
tools/virsh.c | 13 +++++++++++--
tools/virsh.pod | 8 +++++---
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 7d8ae0e..7e65942 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6049,6 +6049,7 @@ static const vshCmdInfo info_vol_pool[] = {
};
static const vshCmdOptDef opts_vol_pool[] = {
+ {"uuid", VSH_OT_BOOL, 0, N_("return the pool uuid rather than pool name")},
{"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume key or path")},
{NULL, 0, 0, NULL}
};
@@ -6058,6 +6059,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
virStorageVolPtr vol;
+ char uuid[VIR_UUID_STRING_BUFLEN];
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
@@ -6077,8 +6079,15 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
return FALSE;
}
- /* Return the name of the parent storage pool */
- vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
+ /* Return the requested details of the parent storage pool */
+ if (vshCommandOptBool(cmd, "uuid")) {
+ /* Retrieve and return pool UUID string */
+ if (virStoragePoolGetUUIDString(pool, &uuid[0]) == 0)
+ vshPrint(ctl, "%s\n", uuid);
+ } else {
+ /* Return the storage pool name */
+ vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
+ }
/* Cleanup */
virStorageVolFree(vol);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e83ea4d..8ef0e96 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -839,10 +839,12 @@ I<vol-name-or-key-or-path> is the name or key or path of the volume to return in
Return the list of volumes in the given storage pool.
I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool.
-=item B<vol-pool> I<vol-key-or-path>
+=item B<vol-pool> [optional I<--uuid>] I<vol-key-or-path>
-Return the pool for a given volume.
-I<vol-key-or-path> is the key or path of the volume to return the pool name for.
+Return the pool name or UUID for a given volume. By default, the pool name is
+returned. If the I<--uuid> option is given, the pool UUID is returned instead.
+I<vol-key-or-path> is the key or path of the volume to return the pool
+information for.
=item B<vol-path> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key>
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH v2] nwfilter: add XML attribute to control match target
by Stefan Berger
This patch adds an optional XML attribute to a nwfilter rule to give the
user control over whether the rule is supposed to be using the state
match or not. A rule may now look like shown in the XML below with the
statematch attribute either having value '0' or 'false' (case-insensitive).
[...]
<rule action='accept' direction='in' statematch='false'>
<tcp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='33'
srcportstart='20' srcportend='21'
dstportstart='100' dstportend='1111'/>
</rule>
[...]
I am also extending the nwfilter schema and add this attribute to a test
case.
V2:
- Following D. Berrange's suggestion I inverted the logic from
'nomatch' XML attribute to statematch attribute
Signed-off-by: Stefan Berger
---
docs/schemas/nwfilter.rng | 10 ++++++++++
src/conf/nwfilter_conf.c | 10 ++++++++++
src/conf/nwfilter_conf.h | 5 +++++
src/nwfilter/nwfilter_ebiptables_driver.c | 3 +++
tests/nwfilterxml2xmlin/tcp-test.xml | 4 ++--
tests/nwfilterxml2xmlout/tcp-test.xml | 4 ++--
6 files changed, 32 insertions(+), 4 deletions(-)
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -1498,6 +1498,9 @@ iptablesCreateRuleInstance(virNWFilterDe
needState = 0;
}
+ if ((rule->flags & RULE_FLAG_NO_STATEMATCH))
+ needState = 0;
+
chainPrefix[0] = 'F';
maySkipICMP = directionIn || inout;
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -1580,6 +1580,7 @@ virNWFilterRuleParse(xmlNodePtr node)
char *action;
char *direction;
char *prio;
+ char *statematch;
int found;
int found_i = 0;
unsigned int priority;
@@ -1595,6 +1596,7 @@ virNWFilterRuleParse(xmlNodePtr node)
action = virXMLPropString(node, "action");
direction = virXMLPropString(node, "direction");
prio = virXMLPropString(node, "priority");
+ statematch= virXMLPropString(node, "statematch");
if (!action) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1633,6 +1635,10 @@ virNWFilterRuleParse(xmlNodePtr node)
}
}
+ if (statematch &&
+ (STREQ(statematch, "0") || STRCASEEQ(statematch, "false")))
+ ret->flags |= RULE_FLAG_NO_STATEMATCH;
+
cur = node->children;
found = 0;
@@ -1677,6 +1683,7 @@ cleanup:
VIR_FREE(prio);
VIR_FREE(action);
VIR_FREE(direction);
+ VIR_FREE(statematch);
return ret;
@@ -2532,6 +2539,9 @@ virNWFilterRuleDefFormat(virNWFilterRule
virNWFilterRuleDirectionTypeToString(def->tt),
def->priority);
+ if ((def->flags & RULE_FLAG_NO_STATEMATCH))
+ virBufferAddLit(&buf, " statematch='false'");
+
i = 0;
while (virAttr[i].id) {
if (virAttr[i].prtclType == def->prtclType) {
Index: libvirt-acl/src/conf/nwfilter_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.h
+++ libvirt-acl/src/conf/nwfilter_conf.h
@@ -345,11 +345,16 @@ enum virNWFilterEbtablesTableType {
# define MAX_RULE_PRIORITY 1000
+enum virNWFilterRuleFlags {
+ RULE_FLAG_NO_STATEMATCH = (1 << 0),
+};
+
typedef struct _virNWFilterRuleDef virNWFilterRuleDef;
typedef virNWFilterRuleDef *virNWFilterRuleDefPtr;
struct _virNWFilterRuleDef {
unsigned int priority;
+ enum virNWFilterRuleFlags flags;
int action; /*enum virNWFilterRuleActionType*/
int tt; /*enum virNWFilterRuleDirectionType*/
enum virNWFilterRuleProtocolType prtclType;
Index: libvirt-acl/docs/schemas/nwfilter.rng
===================================================================
--- libvirt-acl.orig/docs/schemas/nwfilter.rng
+++ libvirt-acl/docs/schemas/nwfilter.rng
@@ -299,6 +299,11 @@
<ref name='priority-type'/>
</attribute>
</optional>
+ <optional>
+ <attribute name="statematch">
+ <ref name='statematch-type'/>
+ </attribute>
+ </optional>
</define>
<define name="match-attribute">
@@ -816,4 +821,9 @@
<param name="maxInclusive">1000</param>
</data>
</define>
+ <define name='statematch-type'>
+ <data type="string">
+ <param name="pattern">([Ff][Aa][Ll][Ss][Ee]|0)</param>
+ </data>
+ </define>
</grammar>
Index: libvirt-acl/tests/nwfilterxml2xmlin/tcp-test.xml
===================================================================
--- libvirt-acl.orig/tests/nwfilterxml2xmlin/tcp-test.xml
+++ libvirt-acl/tests/nwfilterxml2xmlin/tcp-test.xml
@@ -5,14 +5,14 @@
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
- <rule action='accept' direction='in'>
+ <rule action='accept' direction='in' statematch='false'>
<tcp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='33'
srcportstart='20' srcportend='21'
dstportstart='100' dstportend='1111'/>
</rule>
- <rule action='accept' direction='in'>
+ <rule action='accept' direction='in' statematch='0'>
<tcp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='63'
Index: libvirt-acl/tests/nwfilterxml2xmlout/tcp-test.xml
===================================================================
--- libvirt-acl.orig/tests/nwfilterxml2xmlout/tcp-test.xml
+++ libvirt-acl/tests/nwfilterxml2xmlout/tcp-test.xml
@@ -3,10 +3,10 @@
<rule action='accept' direction='out' priority='500'>
<tcp srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32'
dscp='2'/>
</rule>
- <rule action='accept' direction='in' priority='500'>
+ <rule action='accept' direction='in' priority='500' statematch='false'>
<tcp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='32'
dscp='33' srcportstart='20' srcportend='21' dstportstart='100'
dstportend='1111'/>
</rule>
- <rule action='accept' direction='in' priority='500'>
+ <rule action='accept' direction='in' priority='500' statematch='false'>
<tcp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='32'
dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>
14 years, 5 months
[libvirt] [PATCH] virsh: ensure persistence and autostart are shown for dominfo and pool-info
by Justin Clift
This patch adds the persistence status (yes/no) to the output of the virsh
dominfo and pool-info commands. This patch also adds the autostart status
to the output of the virsh pool-info command.
Red Hat BZ for this:
https://bugzilla.redhat.com/show_bug.cgi?id=603696
---
tools/virsh.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 56e1bd7..90fd59e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1903,6 +1903,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom;
virSecurityModel secmodel;
virSecurityLabel seclabel;
+ int persistent = 0;
int ret = TRUE, autostart;
unsigned int id;
char *str, uuid[VIR_UUID_STRING_BUFLEN];
@@ -1956,6 +1957,15 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
ret = FALSE;
}
+ /* Check and display whether the domain is persistent or not */
+ persistent = virDomainIsPersistent(dom);
+ vshDebug(ctl, 5, "Domain persistent flag value: %d\n", persistent);
+ if (persistent < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+
+ /* Check and display whether the domain autostarts or not */
if (!virDomainGetAutostart(dom, &autostart)) {
vshPrint(ctl, "%-15s %s\n", _("Autostart:"),
autostart ? _("enable") : _("disable") );
@@ -5134,6 +5144,8 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolInfo info;
virStoragePoolPtr pool;
+ int autostart = 0;
+ int persistent = 0;
int ret = TRUE;
char uuid[VIR_UUID_STRING_BUFLEN];
@@ -5174,6 +5186,22 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
break;
}
+ /* Check and display whether the pool is persistent or not */
+ persistent = virStoragePoolIsPersistent(pool);
+ vshDebug(ctl, 5, "Pool persistent flag value: %d\n", persistent);
+ if (persistent < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+
+ /* Check and display whether the pool is autostarted or not */
+ virStoragePoolGetAutostart(pool, &autostart);
+ vshDebug(ctl, 5, "Pool autostart flag value: %d\n", autostart);
+ if (autostart < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("no autostart"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no"));
+
if (info.state == VIR_STORAGE_POOL_RUNNING ||
info.state == VIR_STORAGE_POOL_DEGRADED) {
val = prettyCapacity(info.capacity, &unit);
--
1.7.0.1
14 years, 5 months
[libvirt] [PATCH] Adding support for IVM
by Eduardo Otubo
Adding support for the IBM IVM Virtualization system under Power
Hypervisor.
---
src/phyp/phyp_driver.c | 644 ++++++++++++++++++++++++++++++++++--------------
src/phyp/phyp_driver.h | 8 +
2 files changed, 471 insertions(+), 181 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index f8bea42..787b93d 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__)
+#define HMC 0
+#define 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,22 +498,58 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
return virBufferContentAndReset(&tex_ret);
}
+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();
+ goto err;
+ }
+ ret = phypExec(session, cmd, &exit_status, conn);
+
+ VIR_FREE(cmd);
+ VIR_FREE(ret);
+ return exit_status;
+
+ err:
+ VIR_FREE(cmd);
+ VIR_FREE(ret);
+ return -1;
+}
+
/* 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;
char *cmd = NULL;
char *ret = NULL;
- if (virAsprintf(&cmd,
- "lssyscfg -r lpar -m %s --filter lpar_names=%s -F lpar_id",
- managed_system, name) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar -m %s --filter lpar_names=%s -F lpar_id",
+ managed_system, name) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar --filter lpar_names=%s -F lpar_id",
+ name) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -529,15 +575,26 @@ 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) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar -m %s --filter lpar_ids=%d -F name",
+ managed_system, lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar --filter lpar_ids=%d -F name",
+ lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -595,6 +652,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;
@@ -604,21 +663,40 @@ phypGetLparMem(virConnectPtr conn, const char *managed_system, int lpar_id,
if (type != 1 && type != 0)
goto err;
- if (type) {
- if (virAsprintf(&cmd,
- "lshwres -m %s -r mem --level lpar -F curr_mem "
- "--filter lpar_ids=%d",
- managed_system, lpar_id) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (type) {
+ if (virAsprintf(&cmd,
+ "lshwres -m %s -r mem --level lpar -F curr_mem "
+ "--filter lpar_ids=%d",
+ managed_system, lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lshwres -m %s -r mem --level lpar -F "
+ "curr_max_mem --filter lpar_ids=%d",
+ managed_system, lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
} else {
- if (virAsprintf(&cmd,
- "lshwres -m %s -r mem --level lpar -F "
- "curr_max_mem --filter lpar_ids=%d",
- managed_system, lpar_id) < 0) {
- virReportOOMError();
- goto err;
+ if (type) {
+ if (virAsprintf(&cmd,
+ "lshwres -r mem --level lpar -F curr_mem "
+ "--filter lpar_ids=%d", lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lshwres -r mem --level lpar -F "
+ "curr_max_mem --filter lpar_ids=%d",
+ lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
}
@@ -667,27 +745,49 @@ 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;
int exit_status = 0;
int vcpus = 0;
- if (type) {
- if (virAsprintf(&cmd,
- "lshwres -m %s -r proc --level lpar -F "
- "curr_max_procs --filter lpar_ids=%d",
- managed_system, lpar_id) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (type) {
+ if (virAsprintf(&cmd,
+ "lshwres -m %s -r proc --level lpar -F "
+ "curr_max_procs --filter lpar_ids=%d",
+ managed_system, lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lshwres -m %s -r proc --level lpar -F "
+ "curr_procs --filter lpar_ids=%d",
+ managed_system, lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
} else {
- if (virAsprintf(&cmd,
- "lshwres -m %s -r proc --level lpar -F "
- "curr_procs --filter lpar_ids=%d",
- managed_system, lpar_id) < 0) {
- virReportOOMError();
- goto err;
+ if (type) {
+ if (virAsprintf(&cmd,
+ "lshwres -r proc --level lpar -F "
+ "curr_max_procs --filter lpar_ids=%d",
+ lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lshwres -r proc --level lpar -F "
+ "curr_procs --filter lpar_ids=%d",
+ lpar_id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -719,18 +819,30 @@ 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;
int remote_slot = 0;
int exit_status = 0;
- if (virAsprintf(&cmd,
- "lshwres -m %s -r virtualio --rsubtype scsi -F "
- "remote_slot_num --filter lpar_names=%s",
- managed_system, lpar_name) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf(&cmd,
+ "lshwres -m %s -r virtualio --rsubtype scsi -F "
+ "remote_slot_num --filter lpar_names=%s",
+ managed_system, lpar_name) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lshwres -r virtualio --rsubtype scsi -F "
+ "remote_slot_num --filter lpar_names=%s",
+ lpar_name) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -761,6 +873,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;
@@ -772,12 +886,22 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
phypGetRemoteSlot(conn, managed_system, lpar_name)) == -1)
goto err;
- if (virAsprintf(&cmd,
- "lshwres -m %s -r virtualio --rsubtype scsi -F "
- "backing_devices --filter slots=%d",
- managed_system, remote_slot) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf(&cmd,
+ "lshwres -m %s -r virtualio --rsubtype scsi -F "
+ "backing_devices --filter slots=%d",
+ managed_system, remote_slot) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lshwres -r virtualio --rsubtype scsi -F "
+ "backing_devices --filter slots=%d",
+ remote_slot) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -834,6 +958,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;
@@ -841,11 +966,20 @@ phypGetLparState(virConnectPtr conn, unsigned int lpar_id)
char *managed_system = phyp_driver->managed_system;
int state = VIR_DOMAIN_NOSTATE;
- if (virAsprintf(&cmd,
- "lssyscfg -r lpar -m %s -F state --filter lpar_ids=%d",
- managed_system, lpar_id) < 0) {
- virReportOOMError();
- goto cleanup;
+ if (system_type == HMC) {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar -m %s -F state --filter lpar_ids=%d",
+ managed_system, lpar_id) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar -F state --filter lpar_ids=%d",
+ lpar_id) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -877,6 +1011,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;
@@ -884,11 +1019,21 @@ phypGetVIOSPartitionID(virConnectPtr conn)
char *char_ptr;
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) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf(&cmd,
+ "lssyscfg -m %s -r lpar -F lpar_id,lpar_env|grep "
+ "vioserver|sed -s 's/,.*$//g'",
+ managed_system) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar -F lpar_id,lpar_env|grep "
+ "vioserver|sed -s 's/,.*$//g'") < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -915,6 +1060,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;
@@ -923,12 +1069,22 @@ phypDiskType(virConnectPtr conn, char *backing_device)
int vios_id = phyp_driver->vios_id;
int disk_type = -1;
- if (virAsprintf(&cmd,
- "viosvrcmd -m %s -p %d -c \"lssp -field name type "
- "-fmt , -all|grep %s|sed -e 's/^.*,//g'\"",
- managed_system, vios_id, backing_device) < 0) {
- virReportOOMError();
- goto cleanup;
+ if (system_type == HMC) {
+ if (virAsprintf(&cmd,
+ "viosvrcmd -m %s -p %d -c \"lssp -field name type "
+ "-fmt , -all|grep %s|sed -e 's/^.*,//g'\"",
+ managed_system, vios_id, backing_device) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "viosvrcmd -p %d -c \"lssp -field name type "
+ "-fmt , -all|grep %s|sed -e 's/^.*,//g'\"",
+ vios_id, backing_device) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -966,6 +1122,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,16 +1133,29 @@ 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) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar -m %s -F lpar_id,state %s |grep -c "
+ "^[0-9]*", managed_system, state) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf(&cmd,
+ "lssyscfg -r lpar -F lpar_id,state %s |grep -c "
+ "^[0-9]*", state) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -1032,6 +1202,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;
@@ -1049,13 +1220,24 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids,
memset(id_c, 0, 10);
- if (virAsprintf
- (&cmd,
- "lssyscfg -r lpar -m %s -F lpar_id,state %s | sed -e 's/,.*$//g'",
- managed_system, state) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf
+ (&cmd,
+ "lssyscfg -r lpar -m %s -F lpar_id,state %s | sed -e 's/,.*$//g'",
+ managed_system, state) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf
+ (&cmd,
+ "lssyscfg -r lpar -F lpar_id,state %s | sed -e 's/,.*$//g'",
+ 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 +1285,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;
@@ -1112,12 +1295,22 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames)
char *domains = NULL;
char *char_ptr2 = NULL;
- if (virAsprintf
- (&cmd,
- "lssyscfg -r lpar -m %s -F name,state | grep \"Not Activated\" | "
- "sed -e 's/,.*$//g'", managed_system) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf
+ (&cmd,
+ "lssyscfg -r lpar -m %s -F name,state | grep \"Not Activated\" | "
+ "sed -e 's/,.*$//g'", managed_system) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf
+ (&cmd,
+ "lssyscfg -r lpar -F name,state | grep \"Open Firmware\" | "
+ "sed -e 's/,.*$//g'") < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -1272,17 +1465,28 @@ 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;
char *ret = NULL;
- if (virAsprintf
- (&cmd,
- "chsysstate -m %s -r lpar -o on --id %d -f %s",
- managed_system, dom->id, dom->name) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf
+ (&cmd,
+ "chsysstate -m %s -r lpar -o on --id %d -f %s",
+ managed_system, dom->id, dom->name) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf
+ (&cmd,
+ "chsysstate -r lpar -o on --id %d -f %s",
+ dom->id, dom->name) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, dom->conn);
@@ -1304,21 +1508,31 @@ 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;
char *ret = NULL;
- if (virAsprintf
- (&cmd,
- "chsysstate -m %s -r lpar -o shutdown --id %d",
- managed_system, dom->id) < 0) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf
+ (&cmd,
+ "chsysstate -m %s -r lpar -o shutdown --id %d",
+ managed_system, dom->id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf
+ (&cmd,
+ "chsysstate -r lpar -o shutdown --id %d", dom->id) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
-
ret = phypExec(session, cmd, &exit_status, dom->conn);
if (exit_status < 0)
@@ -1363,16 +1577,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);
@@ -1508,6 +1731,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;
@@ -1534,20 +1758,32 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
} else
goto exit;
- if (virAsprintf
- (&cmd,
- "chhwres -r proc -m %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) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf
+ (&cmd,
+ "chhwres -r proc -m %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) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf
+ (&cmd,
+ "chhwres -r proc -id %d -o %c --procunits %d 2>&1 |sed"
+ "-e 's/^.*\\([0-9]\\+.[0-9]\\+\\).*$/\\1/g'",
+ dom->id, operation, amount) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
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;
}
@@ -1564,9 +1800,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 */
@@ -1644,23 +1878,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
@@ -1669,20 +1903,34 @@ 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;
int exit_status = 0;
- if (virAsprintf
- (&cmd,
- "mksyscfg -m %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) {
- virReportOOMError();
- goto err;
+ if (system_type == HMC) {
+ if (virAsprintf
+ (&cmd,
+ "mksyscfg -m %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) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (virAsprintf
+ (&cmd,
+ "mksyscfg -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) < 0) {
+ virReportOOMError();
+ goto err;
+ }
}
ret = phypExec(session, cmd, &exit_status, conn);
@@ -1796,7 +2044,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;
}
@@ -1947,14 +2196,30 @@ phypUUIDTable_Push(virConnectPtr conn)
ConnectionData *connection_data = conn->networkPrivateData;
LIBSSH2_SESSION *session = connection_data->session;
LIBSSH2_CHANNEL *channel = NULL;
+ char *username = NULL;
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) {
+ username = strdup(conn->uri->user);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto err;
+ }
+ }
+
+ if (virAsprintf(&remote_file, "/home/%s/libvirt_uuid_table", username)
+ < 0) {
+ virReportOOMError();
+ goto err;
+ }
if (stat(local_file, &local_fileinfo) == -1) {
VIR_WARN0("Unable to stat local file.");
@@ -2031,6 +2296,7 @@ phypUUIDTable_Pull(virConnectPtr conn)
ConnectionData *connection_data = conn->networkPrivateData;
LIBSSH2_SESSION *session = connection_data->session;
LIBSSH2_CHANNEL *channel = NULL;
+ char *username = NULL;
struct stat fileinfo;
char buffer[1024];
int rc = 0;
@@ -2039,8 +2305,23 @@ 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) {
+ username = strdup(conn->uri->user);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto err;
+ }
+ }
+
+ if (virAsprintf(&remote_file, "/home/%s/libvirt_uuid_table", username)
+ < 0) {
+ virReportOOMError();
+ goto err;
+ }
/* Trying to stat the remote file. */
do {
@@ -2072,7 +2353,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;
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
14 years, 5 months
[libvirt] [PATCH] move ebiptables script out of /tmp
by Jamie Strandboge
Hi,
I noticed today that ebiptablesWriteToTempFile() creates a temporary
file in /tmp that is later executed. It uses mkstemp() and therefore is
safe from symlinks attacks, however, there is not really any reason that
I can see why it is using /tmp instead of somewhere
like /var/lib/libvirt. If libvirtd is confined under a MAC which allows
execution of /tmp/virtd* and a vulnerability is found in libvirtd,
the /tmp path leaves an opportunity for a local non-root attacker to
write a script in /tmp and then subvert libvirt to execute that script.
Putting it in /var/lib/libvirt (or somewhere without world-write
permissions) would prevent this.
I do not consider this a security vulnerability, but rather defensive
programming. Attached is a patch that uses LOCAL_STATE_DIR
"/lib/libvirt/virtdXXXXXX". Feel free to move it somewhere else if
desired. Patch is against head.
Thanks
--
Jamie Strandboge | http://www.canonical.com
14 years, 5 months
[libvirt] [PATCH] macvtap: work-around for 2.6.32 and older kernels
by Stefan Berger
This patch works around a recent extension of the netlink driver I had
made use of when building the netlink messages. Unfortunately older
kernels don't accept IFLA_IFNAME + name of interface as a replacement
for the interface's index, so this patch now gets the interface index
ifindex if it's not provided (ifindex <= 0).
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/util/macvtap.c | 3 +++
1 file changed, 3 insertions(+)
Index: libvirt-acl/src/util/macvtap.c
===================================================================
--- libvirt-acl.orig/src/util/macvtap.c
+++ libvirt-acl/src/util/macvtap.c
@@ -905,6 +905,9 @@ ifaceGetNthParent(int ifindex, const cha
*nth = 0;
+ if (ifindex <= 0 && ifaceGetIndex(true, ifname, &ifindex) != 0)
+ return 1;
+
while (!end && i <= nthParent) {
rc = link_dump(true, ifname, ifindex, tb, &recvbuf);
if (rc)
14 years, 5 months
[libvirt] [PATCH] Add several missing vir*Free calls in libvirtd's remote code
by Matthias Bolte
Justin Clift reported a problem with adding virStoragePoolIsPersistent
to virsh's pool-info command, resulting in a strange problem. Here's
an example:
virsh # pool-create-as images_dir3 dir - - - - "/home/images2"
Pool images_dir3 created
virsh # pool-info images_dir3
Name: images_dir3
UUID: 90301885-94eb-4ca7-14c2-f30b25a29a36
State: running
Capacity: 395.20 GB
Allocation: 30.88 GB
Available: 364.33 GB
virsh # pool-destroy images_dir3
Pool images_dir3 destroyed
At this point the images_dir3 pool should be gone (because it was
transient) and we should be able to create a new pool with the same name:
virsh # pool-create-as images_dir3 dir - - - - "/home/images2"
Pool images_dir3 created
virsh # pool-info images_dir3
Name: images_dir3
UUID: 90301885-94eb-4ca7-14c2-f30b25a29a36
error: Storage pool not found
The new pool got the same UUID as the first one, but we didn't specify
one. libvirt should have picked a random UUID, but it didn't.
It turned out that virStoragePoolIsPersistent leaks a reference to the
storage pool object (actually remoteDispatchStoragePoolIsPersistent does).
As a result, pool-destroy doesn't remove the virStoragePool for the
"images_dir3" pool from the virConnectPtr's storagePools hash on libvirtd's
side. Then the second pool-create-as get's the stale virStoragePool object
associated with the "images_dir3" name. But this object has the old UUID.
This commit ensures that all get_nonnull_* and make_nonnull_* calls for
libvirt objects are matched properly with vir*Free calls. This fixes the
reference leaks and the reported problem.
All remoteDispatch*IsActive and remoteDispatch*IsPersistent functions were
affected. But also remoteDispatchDomainMigrateFinish2 was affected in the
success path. I wonder why that didn't surface earlier. Probably because
domainMigrateFinish2 is executed on the destination host and in the common
case this connection is opened especially for the migration and gets closed
after the migration is done. So there was no chance to run into a problem
because of the leaked reference.
---
daemon/remote.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index c54565c..1fa0f24 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -979,9 +979,10 @@ remoteDispatchDomainMemoryStats (struct qemud_server *server ATTRIBUTE_UNUSED,
/* Allocate stats array for making dispatch call */
if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
+ virDomainFree (dom);
remoteDispatchOOMError(rerr);
return -1;
- }
+ }
nr_stats = virDomainMemoryStats (dom, stats, args->maxStats, 0);
virDomainFree (dom);
@@ -1885,6 +1886,7 @@ remoteDispatchDomainMigrateFinish2 (struct qemud_server *server ATTRIBUTE_UNUSED
}
make_nonnull_domain (&ret->ddom, ddom);
+ virDomainFree (ddom);
return 0;
}
@@ -5570,10 +5572,12 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
ret->active = virDomainIsActive(domain);
if (ret->active < 0) {
+ virDomainFree(domain);
remoteDispatchConnError(err, conn);
return -1;
}
+ virDomainFree(domain);
return 0;
}
@@ -5596,10 +5600,12 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
ret->persistent = virDomainIsPersistent(domain);
if (ret->persistent < 0) {
+ virDomainFree(domain);
remoteDispatchConnError(err, conn);
return -1;
}
+ virDomainFree(domain);
return 0;
}
@@ -5622,10 +5628,12 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
ret->active = virInterfaceIsActive(iface);
if (ret->active < 0) {
+ virInterfaceFree(iface);
remoteDispatchConnError(err, conn);
return -1;
}
+ virInterfaceFree(iface);
return 0;
}
@@ -5648,10 +5656,12 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
ret->active = virNetworkIsActive(network);
if (ret->active < 0) {
+ virNetworkFree(network);
remoteDispatchConnError(err, conn);
return -1;
}
+ virNetworkFree(network);
return 0;
}
@@ -5674,10 +5684,12 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
ret->persistent = virNetworkIsPersistent(network);
if (ret->persistent < 0) {
+ virNetworkFree(network);
remoteDispatchConnError(err, conn);
return -1;
}
+ virNetworkFree(network);
return 0;
}
@@ -5700,10 +5712,12 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
ret->active = virStoragePoolIsActive(pool);
if (ret->active < 0) {
+ virStoragePoolFree(pool);
remoteDispatchConnError(err, conn);
return -1;
}
+ virStoragePoolFree(pool);
return 0;
}
@@ -5726,10 +5740,12 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
ret->persistent = virStoragePoolIsPersistent(pool);
if (ret->persistent < 0) {
+ virStoragePoolFree(pool);
remoteDispatchConnError(err, conn);
return -1;
}
+ virStoragePoolFree(pool);
return 0;
}
--
1.7.0.4
14 years, 5 months
Re: [libvirt] libvirt-python apis
by Alex Jia
Hi pengphy,
http://libvirt.org/python.html
In addition, source code provides some examples about python binding API
under the ./libvirt/python/tests/ directory:
# ls libvirt/python/tests/
basic.py create.py error.py Makefile.am node.py uuid.py
Regards,
Alex
----- Original Message -----
From: pengphy(a)hotmail.com
To: libvir-list(a)redhat.com
Sent: Thursday, June 17, 2010 3:18:08 PM GMT +08:00 Beijing / Chongqing / Hong Kong / Urumqi
Subject: [libvirt] libvirt-python apis
hi, all
I do not know how to use libvirt python apis, and there seems no documents about that, so if anyone has documents or links about python apis please send it to me!
thanks!
Regards,
xpen
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
14 years, 5 months
[libvirt] libvirt-python apis
by pengphy@hotmail.com
hi, all
I do not know how to use libvirt python apis, and there seems no documents about that, so if anyone has documents or links about python apis please send it to me!
thanks!
Regards,
xpen
14 years, 5 months